On click of a button, I am creating a PDF, adding image and text to it, and then saving it to disk.
var pdf = new jsPDF('l', 'pt', [1600, 1000]);
var img = new Image;
img.src = 'http://localhost:29576/Images/logo.png';
img.src = logoUrl;
pdf.addImage(img, 10, 10)
pdf.save();
Now everything works fine and I am able to view this from Chrome. But the moment , I open this from Acrobat Reader, I get an error:
There was an error processing a page. There was a problem reading this document (110)
You have two mistakes:
img.src = ...
two times. In second case you overwrites the first value; onload
. The solution
var pdf = new jsPDF('l', 'pt', [1600, 1000]),
img = new Image,
logoUrl = 'http://localhost:29576/Images/logo.png';
img.onload = function()
{
pdf.addImage(img, 10, 10);
pdf.save('example.pdf');
};
img.src = logoUrl;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.