Add image in pdf using jspdf

前端 未结 12 708
离开以前
离开以前 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:46

    if you have

    ReferenceError: Base64 is not defined

    you can upload your file here you will have something as :

    data:image/jpeg;base64,/veryLongBase64Encode....

    on your js do :

    var imgData = 'data:image/jpeg;base64,/veryLongBase64Encode....'
    var doc = new jsPDF()
    
    doc.setFontSize(40)
    doc.addImage(imgData, 'JPEG', 15, 40, 180, 160)
    

    Can see example here

提交回复
热议问题