Some JPG files give errors
See original GitHub issueI have attached the jpg image that generates the error.
var doc = new jsPDF();
doc.addImage(jpgFile, 'JPEG', 0, 0, 150, 150);
Error message in console:
DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
at Object.b.convertStringToImageData (https://unpkg.com/jspdf@1.4.1/dist/jspdf.min.js:49:8077)
at Object.b.addImage (https://unpkg.com/jspdf@1.4.1/dist/jspdf.min.js:49:6374)
at VueComponent.generatePdf (webpack-internal:///146:215:41)
at VueComponent.boundFn [as generatePdf] (webpack-internal:///9:191:14)
at VueComponent.created (webpack-internal:///146:71:14)
at callHook (webpack-internal:///9:2894:21)
at VueComponent.Vue._init (webpack-internal:///9:4559:5)
at new VueComponent (webpack-internal:///9:4727:12)
at createComponentInstanceForVnode (webpack-internal:///9:4241:10)
at init (webpack-internal:///9:4058:45)
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
Best 9 ways to fix 'Unable to Open JPEG file' error
Best Methods to fix error 'Unable to open JPEG file' · Update to the latest Photo Viewer or Photos App · Use Stellar...
Read more >Can't Open JPG Files in Windows 10? Here's How to Fix It
1. Copy the JPG File and Rename It · 2. Change the File Size · 3. Update the Microsoft Photos App · 4....
Read more >Can't Open JPG Files on Windows 10/11? Solved!
Cause 1: JPEG file got corrupted · If not properly saved or due to some errors or bugs that appear while the image...
Read more >How to Fix Top 5 Common JPEG/JPG Errrors
List of Top 5 JPEG Errrors and their Solutions ; #1. Invalid Value for Registry · Firstly, install the latest drivers. ; #2....
Read more >Top 5 JPEG File Errors and Ways to Fix Them
Common Causes for Corruption/Damage of JPEG format files · Damaged or corrupt header files · Incomplete scanning of files · Bad sectors in...
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
1. You can try another way of adding image. var pdf = new jsPDF(); var img = new Image; img.onload = function() { pdf.addImage(this, 10, 10); pdf.save(“test.pdf”); }; img.crossOrigin = “”; // You can use it if your are using any outsource image… img.src = “”; // Image url
2. Or you can try this link to convert the image in base64 format. https://www.base64-image.de/
1168 is an huge amount of images.
Keeping this issue open for 2 weeks. If not active till then I will close this.