Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add large URLEncoded Images #381

Closed
ddcovery opened this issue Mar 25, 2015 · 2 comments
Closed

Can't add large URLEncoded Images #381

ddcovery opened this issue Mar 25, 2015 · 2 comments

Comments

@ddcovery
Copy link

Hi,
I'm trying to add a large image (10MB, 32Mpx) to the PDF. The image can't be added because this error:

Error while creating order RangeError: Maximum call stack size exceeded
at RegExp.exec (native)

The error is in de PDFImage.open method:

PDFImage.open = function(src, label) {
...
  if (match = /^data:.+;base64,(.*)$/.exec(src)) {
    data = new Buffer(match[1], 'base64');
  }
...
}

I've patched locally to the simpler solution (indexOf and substring) that is faster and requires less memory.

var idx = src.indexOf(";base64,");
if(idx!==-1){
   data = new Buffer(src.substring(idx+8), 'base64')
} else {
@ddcovery ddcovery changed the title Large URLEncoded Images can't be added Can't add large URLEncoded Images Mar 30, 2015
Balearica pushed a commit to Balearica/pdfkit that referenced this issue Mar 3, 2022
@rohinthr
Copy link

rohinthr commented Sep 20, 2023

Any Imporvement in this issue? I facing the similar problem.

@Balearica
Copy link
Contributor

The issue is resolved in my PR (#1349), so any user who encounters can use that. Unfortunately, it does not appear to have been reviewed by a maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants