I am playing around with HTML2PDF; I see a lot of questions about images not loading in the PDF, but cannot find a solution on how to resolve this. I have a very basic page I am playing with. I believe I have the page rendering the image now, but it just stops part way through with no errors. If I remove the image tag; the function works; but if I leave it in, it breaks. Any input would be greatly appreciated.
Code:
<html>
<head>
<script src="https://raw.githack.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js" defer></script>
<style type="text/css">
</style>
</head>
<body align="center">
<div id="view" align="center">
<h1>Export PDF</h1>
<h3>Using HTML2PDF</h3>
<img src="System24-7Logo.jpeg"/>
</div>
<button id="export-pdf">Export PDF</button>
</body>
<script type="text/javascript">
const exportPDF = document.getElementById("export-pdf")
const element = document.getElementById("view");
const opt = {
filename: 'myPage.pdf',
margin: 2,
image: {type: 'jpeg', quality: 0.5},
jsPDF: {format: 'letter', orientation: 'portrait'}
};
// New Promise-based usage:
exportPDF.onclick = (e) => html2pdf().set(opt).from(element).save();
</script>
</html>
Console Log when clicking on Export button:
0ms html2canvas: html2canvas $npm_package_version 72ms html2canvas: Canvas renderer initialized (801x226 at 75.0625,0) with scale 1