Send the correct mime type , and then the contents of the pdf.
fs.readFile('temp/xml/user/username.pdf',function(error,data){ if(error){ res.json({'status':'error',msg:err}); }else{ res.writeHead(200, {"Content-Type": "application/pdf"}); res.write(data); res.end(); } });
I assume res is your response object.
Ah, but you are using Express. Use Jonathan's answer instead.
source share