In my Node/Express app I have the following code, which suppose to read a PDF document from a file, and send it to the browser:
var file = fs.createReadStrea
You have to pipe from Readable Stream to Writable stream not the other way around:
var file = fs.createReadStream('./public/modules/datacollectors/output.pdf');
var stat = fs.statSync('./public/modules/datacollectors/output.pdf');
res.setHeader('Content-Length', stat.size);
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', 'attachment; filename=quote.pdf');
file.pipe(res);
Also you are setting encoding in wrong way, pass an object with encoding if needed.