Exporting PDF with jspdf not rendering CSS

后端 未结 5 1778
深忆病人
深忆病人 2020-11-27 18:13

I am using jspdf.debug.js to export different data from a website but there are a few problems, I can\'t get it to render the CSS in the exported PDF and if I have an image

5条回答
  •  难免孤独
    2020-11-27 19:05

    Slight change to @rejesh-yadav wonderful answer.

    html2canvas now returns a promise.

    html2canvas(document.body).then(function (canvas) {
        var img = canvas.toDataURL("image/png");
        var doc = new jsPDF();
        doc.addImage(img, 'JPEG', 10, 10);
        doc.save('test.pdf');        
    });
    

    Hope this helps some!

提交回复
热议问题