如何使用nodejs将pdf数组缓冲区转换为pdf文件

时间:2020-03-04 09:16:49

标签: node.js express httpresponse pdfkit

以下是pdf缓冲区。我想将缓冲区转换为pdf文件。

data = {
    "file": {
        "type": "Buffer",
        "data": [
            102,
            24,
            62
        ]
    },
}
res.send( data );

1 个答案:

答案 0 :(得分:1)

您可以使用export并使用标题发送一些数据。

// res.sendFile(path [, options] [, fn])

let options = {
  headers: {
      'TheDataYouWantToSend': Date.now() // for example a timestamp
  }
}

req.sendFile(absolutePathToFile, options)

我希望这会有所帮助

相关问题