Invalid String Length When Saving PDF
See original GitHub issueThank you for submitting an issue to jsPDF. Please read carefully.
Are you using the latest version of jsPDF? Yes (1.3.5)
Have you tried using jspdf.debug.js? Yes
Steps to reproduce
- Add images to a jsPDF object that would generate a file string at around 384859244 characters. (~ 130 pages with full page canvas images generated via html2canvas)
- Save File.
- Observe Array.join error due to string being too long. (jspdf.debug.js; line 1051)
What I saw The save function silently fails, and a console log error displays with an Invalid string length error:
index.js:2177 Error in function Array.join (native): Invalid string length RangeError: Invalid string length
at Array.join (native)
at buildDocument (jspdf.debug.js:1051)
at getArrayBuffer (jspdf.debug.js:1073)
at getBlob (jspdf.debug.js:1083)
at Object.<anonymous> (jspdf.debug.js:1112)
at Object.__safeCallWrapper [as output] (jspdf.debug.js:621)
at Object.API.save (jspdf.debug.js:2191)
What I expected I expected the pdf file to save.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Invalid String Length When Saving PDF · Issue #1724 - GitHub
The save function silently fails, and a console log error displays with an Invalid string length error: index.js:2177 Error in function ...
Read more >jsPDF, save method causes 'Uncaught (in promise) RangeError
I am using jsPDF to create a PDF that has around 20 images. The main code does the following: ... Uncaught RangeError: Invalid...
Read more >Error 'Invalid string length' appears when using Export option ...
When exporting data in App Display Line Items in General Ledger following error is received "Invalid string length".
Read more >RangeError: invalid array length - JavaScript - MDN Web Docs
The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds ...
Read more >Invalid String Max Length Error while submitting form - Jotform
I have been testing your form and the error is due to the length of the text added in the "Payment box sub-label"...
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
Actually the problem is that javascript can only handle a specific length of a string. And this is the problem, because the mentioned line is content.join(‘\n’);
We can not modify the string length of the javascript engine. Probably we have to reduce the amount of memory/string length by using compression.
I had this issue as well our reports generate 3000+ pages with images attached. we were running out of memory but as it stands now. We managed to fix the issue. but we are not using html2canvas.