Images of page not rendered to pdf using jsPDF

1k Views Asked by At

I have few images in my web page , i am trying to convert a div element which has images to pdf as :

    var element = document.getElementById(canvasId);
    let doc = new jsPDF('p', 'pt', 'a4');
    doc.addHTML(element, function () {
        doc.save('testdoc.pdf');
    });

The pdf doesn't show images in testdoc.pdf , should i need to add any more attributes ?

A Quick Q :

  • Is it possible to convert full page to image (with all images and styles of web page) similar to pdf by jsPDF with other libraries ?

If so please guide me with some links , any help is much appreciated thanks .

1

There are 1 best solutions below

6
On

After a little surfing and workaround :

  1. Images should be in .JPG

  2. If you are trying any images from say online or from AWS add this below conf :

var opt = {
      image: { type: 'jpeg', quality: 0.98 }, // as per req

      html2canvas: { dpi: 300,
                    letterRendering: true,
                    useCORS: true },
    };