nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.31k stars 29.46k forks source link

How to read memory stream of a pdf and open it #8947

Closed hishobhit82 closed 8 years ago

hishobhit82 commented 8 years ago

Node Version: 5.7.1 Platform: 64-bit (Windows)

Hi, I am a newbie in working with node. I have built an app in electron (which uses node internally) which communicates with a .net restful service to fetch data from db and display it on the screen. One of the data has a pdf path on the server which i read onto the server and convert it into the memory stream and send it to the client app.

The issue how can i read this memory stream in node js and open the pdf file on my windows machine through adobe acrobat reader which is installed on my windows machine? Here is a sample code which i already tried :

var optionsGetPDF= {
           host: 'localhost',
           port: 8080,
           path: '/GetPDFDoc?docid=' + docid,
           method: 'GET'
};

var memStream = new memorystream(null, { readable: false });
http.request(optionsGetPDF, function (res) {
     res.pipe(memStream);
     res.on('end', function () {
          alert(memStream.toString().length)
     });
}).end();

Any help is much appreciated. Thanks and Regards Shobhit

mscdex commented 8 years ago

These kinds of questions are better suited for the node.js help repo. This issue tracker is for reporting bugs in node itself, requesting new features, etc.

hishobhit82 commented 8 years ago

Apologies for posting in the wrong section. Let me move the query there. Thanks !