pdfmake
pdfmake copied to clipboard
Add a Data function to get the PDF string
I added this code to get the full PDF string. It can be useful, and should be added to the code! (If there is any function to this already tell me)
Document.prototype.data = function(cb) {
if (!cb) throw 'data is an async method and needs a callback argument';
try {
this.getBuffer(function(result) {
cb(result.toString('base64'));
});
} catch(e) {
throw e;
}
};
Thanks!
This is available.
Simple example:
const pdfDocGenerator = pdfMake.createPdf(docDefinition);
pdfDocGenerator.getBase64((data) => {
alert(data);
});
@liborm85 Thank you, I've been looking for a way to do that easily.
Thanks!