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

3
我在一个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: 路径必须是字符串"

1个回答

0
看起来如果使用
doc.pipe res
而不是
doc.pipe fs.createWriteStream(res),它应该可以正常工作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接