I am now doing Nodejs, trying generate a PDF using PDFMake. After it's was generate, I want it to be downloaded immediately. However, after downloading the files, I couldn't open the file. It says "Failed to load PDF document." The code I written are below.
var docDefinition = { content: 'test', };
var pdfDoc = printer.createPdfKitDocument(docDefinition);
pdfDoc.pipe(fs.createWriteStream('name.pdf'));
pdfDoc.end();
res.download('name.pdf');