我已經安裝了meteor add jaredmartin:pdfkit,但文檔看起來不正確。我收到第一行的錯誤PDFDocument = require'pdfkit'並且無法通過此操作?是否有流星pdfkit手冊或我在流星0.9上做錯了什麼?如何在流星上使用pdfkit
回答
我也有麻煩。我發現了一箇舊的流星包,它沒有這條線,但我還沒有使它工作。
var doc = new PDFDocument({size: 'A4', margin: 50});
var imageBase64 = Meteor.users.findOne(this.userId).profile.picture;
var imageBuffer2 = new Buffer(imageBase64.replace('data:image/png;base64,','') || '', 'base64');
doc.image(imageBuffer2, 10, 10, {height: 75});
doc.fontSize(12);
doc.text('PDFKit is simple', 10, 30, {align: 'center', width: 200});
// Save it on myApp/public/pdf folder (or any place) with the Fibered sync methode:
doc.writeSync(process.env.PWD + '/public/pdf/PDFKitExample.pdf');
你能推薦任何其他的替代軟件包嗎? – james 2014-10-15 18:13:44
哇,我剛剛看到這個在這裏,我很抱歉這是這麼久,你用我的包有問題。事實是,我當時就是這麼做的,pascual並沒有更新他的原始包裝以與新的流星包裝系統合作,所以我讓我作爲一個權宜之計。從那時起,他已經更新了他的軟件包,所以我建議你使用他的軟件包pascoual:pdfkit
在流星1.1.0.2中,即時通訊使用路由頁面來構建PDF並下載它。
(考慮:包乘:鐵路由器進步和pascoual:pdfkit)
Router.route('/buildPDF/:_param1', function() {
var param1 = this.params._param1;
if (!param1) return;
var doc = new PDFDocument({
size: 'A4',
margins: {
top: 50,
bottom: 0,
left: 50,
right: 50,
}
});
doc.image(process.env.PWD + '/public/img/sample1.jpg', 0, 30, {
width: 598
});
doc.rect(0, 370, 598, 210)
.fill('#22829f', 'even-odd');
doc.fontSize(25).fillColor('white');
doc.text('some text', 50, 390, {
align: 'center',
width: 500
});
...
this.response.writeHead(200, {
'Content-type': 'application/pdf',
'Content-Disposition': 'attachment; filename=sometitle.pdf'
});
this.response.end(doc.outputSync());
}, {
where: 'server'
});
所有作品prefecly,在鍍鉻的PDF自動下載,當我安裝在試驗流星服務器除外,我只是在空白頁面收到消息錯誤
服務器錯誤。
使用流星日誌myapp.meteor.com我得到這個:
W20150615-16:52:09.513(-3)? (STDERR) Error: ENOENT, no such file or directory '/Users/EdU/Documents/Develope/git-repos/TyTimg/layers/sample1.jpg'
W20150615-16:52:09.515(-3)? (STDERR) at Object.fs.openSync (fs.js:439:18)
W20150615-16:52:09.515(-3)? (STDERR) at Object.fs.readFileSync (fs.js:290:15)
W20150615-16:52:09.515(-3)? (STDERR) at Function.PDFImage.open (/Users/EdU/.meteor/packages/pascoual_pdfkit/.1.0.5.7067nv++os+web.browser+web.cordova/npm/node_modules/pdfkit/js/image.js:27:28)
W20150615-16:52:09.515(-3)? (STDERR) at PDFDocument.module.exports.image (/Users/EdU/.meteor/packages/pascoual_pdfkit/.1.0.5.7067nv++os+web.browser+web.cordova/npm/node_modules/pdfkit/js/mixins/images.js:30:26)
變量process.env.PWD寬鬆的背景下進入流星測試服務器。我試圖解決這個問題。我希望能幫助你。
已解決: 我使用過的代碼 'var basePath = process.cwd()+'/../web.browser/app/'; doc.image(basePath +'img/layers/sample1.jpg',0,30);' 並且完美的作品 – EdU 2015-06-17 17:09:40
- 1. 在流星上使用gmaps
- 2. 如何在原生應用上使用流星流?
- 3. 流星如何使用Mori?
- 4. 如何使用流星
- 5. Err_connection_refused使用流星上傳
- 6. 如何在流星中使用FontAwesome?
- 7. 如何在流星中使用jQuery UI?
- 8. 如何在流星中使用回調?
- 9. 如何在流星中使用貓鼬?
- 10. 如何在流星中使用sendEnrollmentEmail
- 11. 如何在流星1.0中使用jQuery
- 12. 如何在流星中使用nodejs包
- 13. 如何使用方法流星流星+離子應用
- 14. 如何在流星
- 15. 如何使用PDFkit的NodeJS
- 16. 如何創建關於如何使用的LinearGradient與pdfkit與pdfkit
- 17. 如何使用流星傳單整合傳單和流星?
- 18. 流星:我如何轉換HTML/HTML5代碼以使用流星?
- 19. 如何在webpack中使用PDFkit庫?
- 20. 如何在流星模板上使用條件?
- 21. 流星 - 如何在密碼上使用服務器端驗證
- 22. 下流星流星?使用引導
- 23. 如何使用jsdoc爲流星應用
- 24. 如何使用流星API調用
- 25. 如何流星
- 26. PDFKit框架可在iPhone OS上使用?
- 27. 流星如何從流星包
- 28. 在星火使用流
- 29. 在流星中使用Crypto.js
- 30. 在流星中使用Typekit
使用pdfmake與流星,pdfmake是pdfkit上的包裝lib – 2016-11-29 04:50:19