eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.04k stars 1.37k forks source link

Set html2pdf().output('datauristring') response in Global variable. #270

Open surajparise opened 4 years ago

surajparise commented 4 years ago

Not able to set html2pdf().output('datauristring') response to global variable which is publicly define. I am using angular 8, i want to upload generated pdf on s3 by form data. i found your some stuff on GitHub for convert pdf to blob and from blob convert to file. but not able to access this datauri pdf string globally for file generation process. this.blobString: any; html2pdf().from(element).set(options).toPdf().output('datauristring').then(function (res) { this.blobString = res; }); console.log(this.blobString);

console output: undefined

Please give a help..

This question raise on stack overflow also, please have a look. https://stackoverflow.com/questions/59200501/upload-html2pdf-generated-pdf-file-on-s3-bucket-by-form-data

vladiks commented 4 years ago

You need to perform console.log and your actions inside .then callback function