Ionic capacitor jspdf add image

I’m trying to use jspdf to add an image to a pdf

the code is really straight (I removed all variable trying to identify where the issue is)

const doc = new jsPDF(); 
base64image= 'data:image/png;base64,iVBORw0KGgoAAAANS......' 
var img = new Image() 
img.src = base64image 
doc.addImage(img, 'png', 10, 10, img.width, img.height) 
doc.save(filename);

The issue is that if I run it in the browser, the pdf is created with the image, but once executed on android phone, the image is a mess, seems stretched or something similar (changing size doesnt fix)

I don’t know really what is the problem. Someone can help? thanks

Hi @chidav77,

I have exactly the same problem, did you resolved it?
When run it in the browser, the pdf is beautiful (images OK)
When run it on android phone, the image is a mess (stretched)

Please advice :slight_smile:

I finally found the solution, please be careful on the way you export the pdf with file.write(…
it causes the trouble… that is why with desktop it was working well.