I need to generate pdf file in using pdfkit in node.js:
I have this code:
doc = new PDFDocument; doc.pipe; fs.createWriteStream('output.pdf'); doc.fontSize(15); doc.text('Generate PDF!'); doc.end(); And it will create a pdf file: 'output.pdf' , but everytime I open the file, the file is corrupted. It says: 'Unable to open document File type plain text document (text/plain) is not supported'.
And then I tried:
doc = new PDFDocument; doc.pipe fs.createWriteStream('output.pdf'); doc.fontSize(15); doc.text('Generate PDF!'); doc.end(); But there's an error saying:
doc.pipe fs.createWriteStream('output.pdf'); ^^ Syntax error: Unexpected Identifier Then, what is the right way to generate pdf files in nodejs? Especially in part of:
doc.pipe fs.createWriteStream Please help me. Thanks in advance!