I am having trouble whit this simple piece of code:
fs.readFile('public/PDF/Booklet_nl.pdf', (err,data)=>{
if(err){
throw err
}
res.send(data);
});
The file can be downloaded but I am not able to visualize the PDF in the browser.
For that, You should set headers as following:
res.setHeader('Content-type', 'application/pdf');
res.setHeader('Content-Disposition', 'attachment; filename=application.pdf');
res.send(data);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.