我尝试过的示例代码:
var PDFDocument = require('pdfkit');
var fs = require('fs');
var doc = new PDFDocument;
doc.pipe(fs.createWriteStream('test.pdf'));
doc.text('hello how r u');
var x= true;
doc.end();
while(x){
console.log("***");
}这段代码没有释放test.pdf,因此我无法打开该文件。如何释放文件,以便应用程序的其余部分可以使用它?
发布于 2014-09-05 02:07:27
这个问题已经在github上讨论过了。建议在写入流完成时执行某些操作的方式是查看流上的finish事件:
stream.on( 'finish', function() { ..... } );https://stackoverflow.com/questions/25669265
复制相似问题