How to set image to fit width of the page using jsPDF?

后端 未结 11 2163
醉话见心
醉话见心 2020-12-04 21:37

Is there any way to solve this? I tried to set width and height in mm. How can I set it to full-width?

11条回答
  •  粉色の甜心
    2020-12-04 22:17

    i faced same problem but i solve using this code

    html2canvas(body,{
                    onrendered:function(canvas){
                        var pdf=new jsPDF("p", "mm", "a4");
                        var width = pdf.internal.pageSize.getWidth();    
                        var height = pdf.internal.pageSize.getHeight();
                        pdf.addImage(canvas, 'JPEG', 0, 0,width,height);
                        pdf.save('test11.pdf');
                    }
                }) 
    

提交回复
热议问题