Overall Goal
- Generate a pdf of the currently displayed html page;
- Pass it to the server-side;
- Save into a specific Google Drive
Item 2 is the one I'm having trouble with!
I'm using this to try to get the converted file passed to the server-side:
Client Side
function saveToGDrive(){
var element = document.getElementById('pgBody');
var opt = {
margin: 1,
filename: 'myfile.pdf',
image: {
type: 'jpeg',
quality: 0.98
},
html2canvas: {
scale: 5
},
jsPDF: {
unit: 'in',
format: 'A4',
orientation: 'landscape'
}
};
const pg = html2pdf().set(opt).from(element).outputPdf().then(function(p) {
console.log('PDF file: ' + typeof btoa(p))
return btoa(p);
});
google.script.run.savePdf(pg)
}
Item 2 gives me the error: Failed due to illegal value in property: state and I'm taking the variable pg is too large to be passed as a parameter like this.
Appreciate any help!