Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在node.js中使用pdfkit发送HTTP响应_Node.js_Pdfkit - Fatal编程技术网

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

在node.js中使用pdfkit发送HTTP响应,node.js,pdfkit,Node.js,Pdfkit,我正在node.js express 3项目中使用pdfkit 0.6.1 我想将PDF作为HTTP响应发送,而不是保存在服务器上 上的示例说明如何使用: # HTTP response doc.pipe fs.createWriteStream(res) # add stuff to PDF here # finalize the PDF and end the stream doc.end() 然而,我得到了一个错误:“500 TypeError:path必须是字符串”如果我使用 d

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

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

上的示例说明如何使用:

# 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)