React js: addImage is not a function
See original GitHub issueI’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?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
React js: addImage is not a function · Issue #2184 - GitHub
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 *...
Read more >addImage error (Cannot read property ... - Stack Overflow
Everything seems to work OK, I can create, save the pdf, position the text, I can call the function "backgroundimage" (tested it with...
Read more >Images - React Native
React Native provides a unified way of managing images and other media assets in your Android and iOS apps. To add a static...
Read more >Require Image Not Working in ReactJS - YouTube
Learn how to add image in react js or add image in react js. React image is used with simple img tag in...
Read more >JsPDF addimage is not a function - Yo Motherboard
There appears to be a bug with the older version of this framework for some people. If you have downloaded the latest version...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@longtd269 i met this problem just now. it’s a duplicate bug, you should lock your jspdf version now, like “~1.4.1”
Version 1.5.3 got released and fixes the issue.