html2pdf creates a blank PDF and somethings shows a security error 'The operation is insecure' on iOS 16.x.x
Hi,
The html2pdf.js creates a Blank PDF or throws an error 'The operation is insecure' on new iOS 16.0.2.
Below is the html2pdf config:
function generatePDF(true) {
return new Promise(function(resolve, reject) {
var element = document.getElementById("main");
var options = {
filename: 'document.pdf',
image: {
type: 'jpeg',
quality: 0.5
},
html2canvas: {
scrollX: 0,
scrollY: 0,
scale: window.devicePixelRatio && window.devicePixelRatio > 1 ? 0.8 : 1
},
jsPDF: {
unit: 'pt',
format: 'a4',
orientation: 'portrait'
}
};
var pdf = html2pdf().set(options).from(element);
pdf.outputPdf('datauristring').then(function(data) {
// if (true)
// pdf.save();
resolve({
data: data.replace("data:application/pdf;filename=generated.pdf;base64,", ""),
type: "data:application/pdf"
});
}).catch(function(e) {
alert('catch: ' + e);
reject();
});
});
}
html2pdf.js version: 0.10.1 https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js
I have noticed, 'scale' property of 'html2canvas' creates the security error. However, the above code works in earlier version of iOS.
I wonder what am I missing out from the config?
Thanks
Hi @eKoopmans, do you have any fix of the above issue?
same issue here. version 0.10.1 seems unusable.
same issue here. version 0.10.1 seems unusable.
did you find any solution of the problem?
Still not working on iOS
Reducing the quality solved the problem here.
For me the fix for iOS was simply to change html2pdf to html3pdf. import html3pdf from 'html3pdf'; const worker = html3pdf() .set(opt) .from(element) .toPdf() .get('pdf') .save();