繁体   English   中英

在node.js中使用pdfkit发送HTTP响应

[英]using pdfkit in node.js to send an HTTP response

我在node.js express 3项目中使用pdfkit 0.6.1。

我想将PDF作为HTTP响应发送,而不是将其保存在服务器上。

http://pdfkit.org/docs/getting_started.html上的示例说使用:

# HTTP response
doc.pipe fs.createWriteStream(res) 

# add stuff to PDF here

# finalize the PDF and end the stream
doc.end()

但是我收到一个错误,上面写着:“500 TypeError:path必须是一个字符串”

看起来如果我使用它会工作正常
doc.pipe res
代替
doc.pipe fs.createWriteStream(res)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM