1

I am working on my website project in Laravel, and I want to use the new version of jsPDF which is 2.5.2. Here is the js file I have:

document.getElementById('exportPDF').addEventListener('click', function() {
    var { jsPDF } = window.jspdf.jsPDF;
    var doc = new jsPDF();
    doc.autoTable({ html: '#Table1' });
    doc.save('AccountList.pdf');
});
//in the blade file
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.2/jspdf.umd.min.js"></script>

The console error message

 Uncaught TypeError: Cannot read properties of undefined (reading 'jsPDF')

The older version of jsPDF like 2.3.1 can work using window.jspdf;

var { jsPDF } = window.jspdf;

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.