Add image in pdf using jspdf

前端 未结 12 697
离开以前
离开以前 2020-12-05 06:49

I am using jspdf to convert an image into a PDF.

I have converted the image into a URI using base64encode. But the problem is that there are no errors or warnings sh

12条回答
  •  伪装坚强ぢ
    2020-12-05 07:34

    I had the same issue with Base64 not being defined. I went to an online encoder and then saved the output into a variable. This probably is not ideal for many images, but for my needs it was sufficient.

    function makePDF(){
        var doc = new jsPDF();
        var image = "data:image/png;base64,iVBORw0KGgoAA..";
        doc.addImage(image, 'JPEG', 15, 40, 180, 160);
        doc.save('title');
    }
    

提交回复
热议问题