jsPDF - html - Image issue
jsPDF - render pdf from html - Image issue
by ganesh095
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.2.2/purify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.0/jspdf.umd.min.js"></script>
<div id="imageDiv">
<button class="downloadPdf" onclick="myFunction()">
Download
</button>
<img id="imageid1" width="150" height="100" src='https://i.ibb.co/Scxrxjw/23008179-PK-front.jpg' />
<img id="imageid2" width="150" height="100" src='https://i.ibb.co/TtRDQ9V/23008194-BX-front.jpg' />
<img id="imageid3" width="150" height="100" src='https://i.ibb.co/j5TrS5Z/cat-llooking-at-camera.jpg' />
</div>
JavaScript
var jsPDF = window.jspdf.jsPDF;
function myFunction() {
var doc = new jsPDF({ orientation: 'p', format: 'a4', unit: 'pt'});
doc.html(document.getElementById('imageDiv'), {
callback: function (doc) {
doc.save('sample-file.pdf');
},
x: 10,
y: 10,
//width: 595,
//windowWidth: 1095,
html2canvas: {
allowTaint : false,
useCORS: true,
logging: true
}
});
}