cesarvr / pdf-generator

Cordova plugin to generate pdf in the client-side
MIT License
107 stars 61 forks source link

Blank PDF file is generated when called first time #131

Open Ramya-Kakarla opened 3 years ago

Ramya-Kakarla commented 3 years ago

Below is the code snippet to generate and save the pdf directly into the file system. Getting the html as shown below. ` var htmlContent = document.getElementById('page-content'); var pdfhtml =''+ '
'+ htmlContent.innerHTML + '';

var fileName = file + ".pdf"; var options = { documentSize: 'A4', type: 'base64' }; pdf.fromData(pdfhtml, options) .then(function (base64) { var contentType = "application/pdf"; var folderpath = cordova.file.externalRootDirectory + "Download/"; savebase64AsPDF(folderpath, fileName, base64, contentType); }) .catch(function (e) { console.log(e) });`

It's generating a blank PDF when called the first time. Works fine in the subsequent calls. No errors are shown when the blank file is generated.

maqeelqureshi commented 1 year ago

How did you resolve it?