pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Add a Data function to get the PDF string

Open driconmax opened this issue 10 years ago • 3 comments

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!

driconmax avatar Dec 01 '16 13:12 driconmax

This is available.

Simple example:

const pdfDocGenerator = pdfMake.createPdf(docDefinition);
pdfDocGenerator.getBase64((data) => {
	alert(data);
});

liborm85 avatar Dec 30 '16 13:12 liborm85

@liborm85 Thank you, I've been looking for a way to do that easily.

Chris--A avatar Dec 31 '16 07:12 Chris--A

Thanks!

driconmax avatar Jan 02 '17 12:01 driconmax