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

我在一个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必须是一个string”

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