I have searched for a long time but nothing helps. I have two files header.php and other.php.
My header.php
it looks like this:
<head>
.....
</head>
<header>
.....
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
</header>
I require the header.php
in other.php
and want to use jsPDF in this file:
require "header.php";
<body>
....
</body>
<script>
function createInvoice(final){
const doc = new jsPDF();
doc.text("Hello world!", 10, 10);
doc.save("a4.pdf");
}
</script>
I tried with the script to include jsPDF in the body tag, in the head tag and over the script tag with the function, but every time I am getting the following error :
Uncaught ReferenceError: jsPDF is not defined
Can someone help me? Thank you in advance
In the new release, they changed the name of the global variable -> const { jsPDF } = window.jspdf
.
<script>
window.jsPDF = window.jspdf.jsPDF; // add this line of code
function createInvoice(final){
const doc = new jsPDF();
doc.text("Hello world!", 10, 10);
doc.save("a4.pdf");
}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With