5
votes

I have borrowed the code from here and I am trying to make it work as a proof of concept in my React application.One of the issues I encounter is with line:

var pdf = new jspdf('p', 'pt', 'letter');

In such case I get the following error: TypeError: WEBPACK_IMPORTED_MODULE_2_jspdf.jspdf is not a constructor

If I remove 'new' var pdf = jspdf('p', 'pt', 'letter');

I am getting the error: TypeError: Object(...) is not a function

What am I doing wrong. It seems like it is working in all examples, but no in my editor :)

1
what does console.log(jspdf) give? - Keith
is it possbile the script is not yet loaded, did you check for that - Dellirium
@Keith, nothing it breaks on the aforementioned command itself. - py_script
@Dellirium what do you mean? - py_script
Do you get -> Uncaught ReferenceError: jspdf is not defined by any chance? - Keith

1 Answers

1
votes

It's a typo

const jsPDF = require('jspdf')
var pdf = new jsPDF('p', 'pt', 'letter')