Search code examples
javascriptjspdf

TypeError: Method Promise.prototype.then called on incompatible receiver -JSPDF


Getting Error while generating pdf using JSPDF - Error: TypeError: Method Promise.prototype.then called on incompatible receiver,

Below is the code and I am using version 2.4.0

const doc = new jsPDF.jsPDF({ unit: 'pt', putOnlyUsedFonts: true});
const pdfElement = document.getElementById('id');
var pdfName = 'Test.pdf';
doc.html(pdfElement, {
    callback: (pdf) => {
      pdf.save(pdfName)
    },
    margin: 20,
});

Environment - AngularJs and RequireJs


Solution

  • I encountered the exact issue with the latest (v2.5.1) version.

    It turned out that it is not an issue with jspdf. Instead, it was the NewRelic agent causing the issue.

    If you are using the Lit New Relic browser agent type, change it to Pro agent type. To do so: