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.
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.