title says it all
Download these:
blob-stream.js from https://github.com/devongovett/blob-stream/releases
FileSaver.js from https://github.com/eligrey/FileSaver.js/
pdfkit.js from http://pdfkit.org/
Then include them in your webpage in that order.
Start your Javascript like this:
var doc = new PDFDocument();
var stream = doc.pipe(blobStream());
.....Do your PDF code here, and end with....
doc.end();
stream.on('finish', function() {
blob = stream.toBlob('application/pdf');
// Line below uses FileSaver.js
saveAs(blob, 'MyFile.pdf');
});
i'm getting "Uncaught TypeError: Invalid non-string/buffer chunk" on "blob-stream.js:3380 "
I want to save my generated pdf by calling the api from a download method in UI. I have tried this but not working, instead getting an error stating that stream.on is not a function. Can anyone please help me on this ?
@lokeshdasari please send a sample of the code
You can look also at pdfmake implementation of helper functions to save pdf
Most helpful comment
Download these:
blob-stream.js from https://github.com/devongovett/blob-stream/releases
FileSaver.js from https://github.com/eligrey/FileSaver.js/
pdfkit.js from http://pdfkit.org/
Then include them in your webpage in that order.
Start your Javascript like this:
.....Do your PDF code here, and end with....