📜  jspdf 减小文件大小 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:44.278000             🧑  作者: Mango

代码示例1
function genPDF() {

  html2canvas(document.querySelector(".page"), {scale: "2"}).then(canvas => {

    this.imgFile = canvas.toDataURL("image/jpeg", 0.3);
    var doc = new jsPDF('p', 'mm', 'a4', true);
    //and here is the trick, use FAST to add the canvas or any image:
    doc.addImage(this.imgFile, "JPEG", 5, 0, 210, 297, undefined,'FAST');
    doc.save('Test.pdf');

  });

}