Jspdf: File with 120 images/pages crashes Chrome

Created on 11 Oct 2016  Â·  10Comments  Â·  Source: MrRio/jsPDF

I've tried the latest version and a few prior versions of jspdf with large amounts of data, and Chrome crashes each time - sometimes with 70 images, other times with 85-90. There are 120 total datauri images, and they are complex map images. Internet Explorer, ironically, allows it to work though it takes 3 to 7 minutes. The memory in both browsers, though, gets really high and ultimately causes Chrome to crash. I've tried changing the image compression setting with jspdf which does make a difference in both browsers, but I'm still unable to generate it in Chrome. Any suggestions or ideas?

Most helpful comment

I think the problem is the addImage-Plugin.
https://github.com/MrRio/jsPDF/blob/master/plugins/addimage.js

Every Image is saved as base64-Text into an Object (line 134). So instead of loading and processing and then kicking it out of the memory, it keeps the images in the memory. There is not even a delete action after it is put into the pdf (line 108), because you dont know if it is used again in another place in the pdf.

All 10 comments

What is it you're rendering? HTML / Canvas / SVG? There might be a better
way than as images
On Tue, 11 Oct 2016 at 21:53, atdiff [email protected] wrote:

I've tried the latest version and a few prior versions of jspdf with large
amounts of data, and Chrome crashes each time - sometimes with 70 images,
other times with 85-90. There are 120 total datauri images, and they are
complex map images. Internet Explorer, ironically, allows it to work though
it takes 3 to 7 minutes. The memory in both browsers, though, gets really
high and ultimately causes Chrome to crash. I've tried changing the image
compression setting with jspdf which does make a difference in both
browsers, but I'm still unable to generate it in Chrome. Any suggestions or
ideas?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/MrRio/jsPDF/issues/901, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAC5s3sZZZT5J5HFfVMizJZE4km3Z29Mks5qy_dGgaJpZM4KUF8a
.

James Hall
Director
Parallax Agency Ltd
M. 07894950320

They're png datauri's that I'm just adding to the page

I think the problem is the addImage-Plugin.
https://github.com/MrRio/jsPDF/blob/master/plugins/addimage.js

Every Image is saved as base64-Text into an Object (line 134). So instead of loading and processing and then kicking it out of the memory, it keeps the images in the memory. There is not even a delete action after it is put into the pdf (line 108), because you dont know if it is used again in another place in the pdf.

I am facing the same issue when I try to add 14 Images to a PDF

@atdiff @jeanPokou @arasabbasi I have solved this problem.actually you need to change arrayBufferToBinaryString function in addImage js.

@ashakoshti1988 Hey, oh nice, can you post the fix as a PR?

@MrRio In addimage.js the below function rotates as many times per character based on base64 conversion.

jsPDFAPI.arrayBufferToBinaryString = function(buffer) .Just comment the function body and uncomment the below line,
return atob(this.arrayBufferToBase64(buffer));

http://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers

@MrRio i need UTF-8 Conversion in my pdf.even i can develop it in jspdf functionality,but the help is appriciated.so just guide me how to start and from where can i start??

844

425

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MelanieCroce picture MelanieCroce  Â·  4Comments

palmoni picture palmoni  Â·  4Comments

baluMallisetty picture baluMallisetty  Â·  4Comments

allenksun picture allenksun  Â·  3Comments

mellisa0109 picture mellisa0109  Â·  3Comments