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;