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.

Invalid String Length When Saving PDF

See original GitHub issue

Thank 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

  1. 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)
  2. Save File.
  3. 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:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
Uzlopakcommented, May 27, 2018

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.

2reactions
Custardcscommented, May 16, 2018

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.

Read more comments on GitHub >

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

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