jsPDF addImage does not support file type "UNKNOWN" in IE11

Viewed 1366

I'm using jsPDF to generate certificates of completion for elearning courses. We have the certificates working as expected in Chrome, FF and Edge, but IE11 won't generate the PDF. jspdf.debug.js (v1.4.1) is throwing: "addImage does not support files of type "UNKNOWN".

Here's our script:

function createCert() {
    // This is the function that will generate a PDF from an image and text fields.
    var imgBackground = new Image();
    imgBackground.src = "Opioid_1.jpg";
    imgBackground.onload = function () {
        var doc = new jsPDF({
            orientation: 'landscape',
            unit: 'in',
            format: [11, 8.5]
        });
  doc.addImage(imgBackground, "JPEG", 0.2, 0, 10.5, 8.1);
        // dummy data
        var userName = "John Smith";
        var fileName = "CertPDF.pdf";
        var courseTitle = "Basics 101";
        var dateCompleted = "09/10/2010";
        
        doc.setFontSize(12);
        doc.setTextColor(0, 0, 0);
        doc.setFont("helvetica");
        doc.setFontType("bold");
        doc.text(4.6, 6.0, userName, null, null, 'left');
  doc.setFontType("normal");
        doc.text(.46, 3.6, dateCompleted, null, null, 'left');
        doc.text(.46, 1.9, courseTitle, null, null, 'left');
  doc.text(.46, 4.4, userName, null, null, 'left');

        doc.save(fileName);
    };
}

0 Answers
Related