-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
I'm using jsPDF for react project.
I have error: addImage is not a function
jsPDF version:
"jspdf": "^1.4.1"
This is mycode:
import * as jsPDF from 'jspdf'
html2canvas(input, {useCORS: true})
.then((canvas) => {
const imgData = canvas.toDataURL('image/png');
let imgWidth = 210;
let pageHeight = 297;
let imgHeight = canvas.height * imgWidth / canvas.width;
let heightLeft = imgHeight;
let doc = new jsPDF('p', 'mm', 'a4');
let position = 0;
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
while (heightLeft >= 0) {
position = heightLeft - imgHeight;
doc.addPage();
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
}
doc.save("test.pdf");
}) ;
Did i do something wrong?
Metadata
Metadata
Assignees
Labels
No labels