question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some JPG files give errors

See original GitHub issue

I 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)

achterkant

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
jhashubhamcommented, Jun 9, 2018

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/

0reactions
Uzlopakcommented, Jun 7, 2018

1168 is an huge amount of images.

Keeping this issue open for 2 weeks. If not active till then I will close this.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found