score:0

Instead of sending buffer to the front end try this.

Front end -

download2016(){
   window.open("http://localhost:5000/download/report/2016")
}

Backend Code -

const router = require('express').Router();
const fs = require('fs');
const path = require('path');

router.get('/report/2016',function(req, res){
   var tempfile = __dirname +  '\\mypdfname.pdf';
   res.download(tempfile, function(err) {
         if(err) {
             console.log('Something went wrong : ', err)
         } else {
             console.log('File downloaded.') 
         }
   });
});
module.exports = router;

Related Query

More Query from same tag