I want to generate a PDF from a hta file (http-equiv="x-ua-compatible" content="ie=11"). Append to child is working like a charme. However it doesn't work with jsPDF... Any help appreciated!
Scripts included:
<script src="polyfill.min.js"></script><!-- https://cdn.jsdelivr.net/npm/promise-polyfill@7/dist/polyfill.min.js -->
<script src="jspdf.js"></script><!-- https://github.com/MrRio/jsPDF/blob/master/src/jspdf.js -->
<script src="html2canvas.js"></script><!-- https://html2canvas.hertzen.com/dist/html2canvas.js -->
DIV to print:
<div class ="print" id="print">
<h3>print!</h3>
<input type="button" id="pdfPrint" value="PDF erstellen" />
</div>
Script Code:
document.getElementById('pdfPrint').addEventListener('click', function() {
html2canvas(document.getElementById("print")).then(function(canvas) {
// document.getElementById("print").appendChild(canvas);
var img = canvas.toDataURL("image/jpeg", 1.0);
var pdf = new jsPDF();
pdf.addImage(img,'JPEG',20,20);
pdf.save('Testung.pdf');
}
});
});
I've made a test with your code. And I've found that there will be ReferenceError: 'jsPDF' is undefined in IE11.
The key point is the reference of jsPDF. You should replace your jsPDF script with latest one:https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js