How do I save buffer as PDF in client side(in browser on response as buffer) ?
See original GitHub issueThis is how I sending buffer in the response.
htmlToPDF.create(finalHTML, options).toBuffer((err, buffer) => {
if (err) {
res.json(responses.genericError(500, 'Internal server error.'));
} else {
res.type('application/pdf');
res.statusCode = 200;
res.send({ data: buffer, success: true });
}
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:13
Top Results From Across the Web
How to output a PDF buffer to browser using NodeJS?
Try this in client side: var oReq = new XMLHttpRequest(); oReq.open("GET", url, true); oReq.responseType = "arraybuffer"; oReq.onload ...
Read more >How can I serve a PDF to a browser without storing a file on ...
How can I serve the PDF file to the client without storing the file on the server side and allow the client side...
Read more >Puppeteer HTML to PDF Generation with Node.js
It is possible to generate a PDF file both on the client-side and on ... the PDF won't be saved to the disk,...
Read more >How to create PDF files - Django documentation
The response will automatically set the MIME type application/pdf based on the filename extension. This tells browsers that the document is a PDF...
Read more >Methods - PDFMake
Download the PDF · Open the PDF in a new window · Print the PDF · Put the PDF into your own page...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is the code that I’ve written to download pdf on the client side,
@lowzijian If you have
res.setHeader('Content-disposition', 'attachment; filename=export-from-html.pdf'); // Remove this if you don't want direct download
It will automatically popup the “file open or download” on the response of your “controller”. But if you comment this line, your browser will open the stream with a PDF reader (eg Firefox).Here is my code if you want :