NodeJS - 使用pdfmake在飞行中生成PDF。

问题描述 投票:0回答:1

我想在我的NodeJS应用中,用pdfmake在服务器端生成一个PDF,但我不知道怎么做。我想不把它保存在我的服务器上。

我有这个

const printer = new PdfPrinter( fonts );
const pdfKitDoc = printer.createPdfKitDocument( dd );
const stream = pdfKitDoc.pipe( ... );
pdfKitDoc.end();
return stream;

我不知道我必须输入什么来代替'...'。如果可以的话,我想把它流为blob,在我的应用程序中使用。

谁能帮帮我?

谅谅

node.js pdfmake
1个回答
1
投票

我解决了我的问题,感谢 @Thee Sritabtim。

  1. 安装 流对数组
  2. 然后

return toArray( doc ).then( parts => {
   return Buffer.concat( parts );
} );
© www.soinside.com 2019 - 2024. All rights reserved.