html2pdf.js
html2pdf.js copied to clipboard
How to save pdf file on server?
How can the output pdf file be saved on the server using script?
I have the same need
I'm looking for that, too
I found a way to get base64 data. The code is as follows:
var element = document.getElementById('zPrintDiv');
var worker = html2pdf(element).toPdf();;
worker = worker.output("datauristring").then(function (pdf) {
console.log("conve pdf ok:")
console.log(pdf);//this is base64 Data
});
I found a way to get base64 data. The code is as follows:
var element = document.getElementById('zPrintDiv'); var worker = html2pdf(element).toPdf();; worker = worker.output("datauristring").then(function (pdf) { console.log("conve pdf ok:") console.log(pdf);//this is base64 Data });
Using the above method generates a double of the first page when I convert the base64 into pdf using the following code in Firefox:
$base_to_php = explode(',', $baseFromJavascript);
$data = base64_decode($base_to_php[1]);
header('Content-Type: application/pdf');
echo $data;
Is there any way around this?