【发布时间】:2016-08-20 09:13:14
【问题描述】:
我在我的流星应用程序上使用 pdfKit 和 FlowRouter。我想生成一个 pdf 文件而不将其保存在服务器上。在文档中有一个例子:
Router.route('/getPDF', function() {
var doc = new PDFDocument({size: 'A4', margin: 50});
doc.fontSize(12);
doc.text('PDFKit is simple', 10, 30, {align: 'center', width: 200});
this.response.writeHead(200, {
'Content-type': 'application/pdf',
'Content-Disposition': "attachment; filename=test.pdf"
});
this.response.end( doc.outputSync() );
}, {where: 'server'});
但这是用于 Iron Router 的。由于我使用的是 FlowRouter,我不知道如何在不将文件保存在服务器上的情况下直接向用户显示/下载 pdf。
【问题讨论】:
标签: meteor pdf-generation flow-router