I am using the eKoopmans html2pdf.js library to create a PDF after submitting a form. It all is working perfectly in all browsers and in all devices but not on iOS.
There I have the problem, that all my input fields dont render the value of it. The input fields are just empty. I am using the following code to create the PDF.
var element = document.getElementById('testtest');
opt = { margin: 0.05,
filename: 'myfile.pdf',
image: { type: 'jpeg', quality: 0.98 },
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' },
html2canvas: { scale: 2 },
pagebreak: { mode: ['css', 'legacy'], after: '.breakme' }
};
$('.btn').hide();
html2pdf().from(element).set(opt).toPdf().output('datauristring').then(function (pdfAsString) {
And idea why this is not working on iOS?
Of course I also found this: https://github.com/niklasvh/html2canvas/issues/1338
But this didn't fix the problem on iOS.
this must be about update of Chrome V87 or higher.
So you can try, replace your inputs to span, let me give some code, unless with this you can render all your forms:
(btw -> you have to do, for each input, add a class named as "data")
$("input.data").each(function(i,v) { let val = v.value; $(this).replaceWith("<span>" + val + "</span>"); });
Its working... again! (and I hope for the rest of time!) There is some comments about this bugfix: Niklasvh/html2canvas/issues/1338
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.