How to download pdf file from url in node.js? -


i creating application download pdf files url , show in dashboard page grid wise.

i using node.js express framework.

exports.pdf = function(req, response) {     var url ="http://www.ieee.org/documents/ieeecopyrightform.pdf";      http.get(url, function(res) {      var chunks = [];      res.on('data', function(chunk) {      console.log('start');      chunks.push(chunk);     });      res.on("end", function() {       console.log('downloaded');       var jsfile = new buffer.concat(chunks).tostring('base64');       console.log('converted base64');       response.header("access-control-allow-origin", "*");       response.header("access-control-allow-headers", "x-requested-with");       response.header('content-type', 'application/pdf');      response.send(jsfile);     });     }).on("error", function() {    console.log("error");    });  }; 

this help.

response.setheader("content-type", "text/pdf"); 

this link help


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -