【问题标题】:using pdfkit in node.js to send an HTTP response在 node.js 中使用 pdfkit 发送 HTTP 响应
【发布时间】:2014-05-08 15:14:28
【问题描述】:

我在 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 must be a string”

【问题讨论】:

    标签: node.js pdfkit


    【解决方案1】:

    如果我使用它看起来会很好用
    doc.pipe res
    而不是
    doc.pipe fs.createWriteStream(res)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-17
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 2012-12-16
      • 1970-01-01
      • 2020-02-08
      • 1970-01-01
      相关资源
      最近更新 更多