Skip to content

JPG shown, but PNG images are not included #749

@j-kaltes

Description

@j-kaltes

I use html2pdf.js with the following code:

<!DOCTYPE html>
    <html>
    <head>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.2/html2pdf.bundle.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js" integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
    </head>

    <body >
    <button id="download">Download PDF</button>
    <div id="report">
    <h1>Header</h1>
    <p>
    Some Text
    </p>
    <img src="https://assets.ubuntu.com/v1/d639b982-canonical-brand-tile.png">
   <p>
   Above this text is a PNG picture, below a JPG picture.
   </p>
    <img src="https://image-tc.galaxy.tf/wijpeg-esipt0y72wzich0blxcn0h1x1/cmh-snow-2.jpg">
   </div> 

    <script>
        document.getElementById('download').addEventListener('click', () => {
            const element = document.getElementById('report');
            const options = {
                margin: 0.05,
                filename: 'report.pdf',
                enableLinks:  true,
                html2canvas: { scale: 1, useCORS: true },
                jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait', compressPDF: true}
            };
           html2pdf()
                    .from(element)
                    .set(options)
                    .save();
                });
    </script>
    </body>
    </html>

But the PNG images are not shown. JPG images are. I tried all kinds of suggestions metioned in other issues without effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions