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

doc.image() is broken for file sizes > 16kb on node.js 20.3 #1453

Open
malte94 opened this issue Jun 25, 2023 · 2 comments
Open

doc.image() is broken for file sizes > 16kb on node.js 20.3 #1453

malte94 opened this issue Jun 25, 2023 · 2 comments

Comments

@malte94
Copy link

malte94 commented Jun 25, 2023

Description of the problem

I am using node.js 20.3.1 and pdfkit 0.13.0.

The doc.image() function seems to be broken when using files larger than 16kb. So basically for every image. A picture with 13,4kb was the smallest (and smaller) I could possibly attach to the doc.

Code sample

    if (fs.existsSync(FileSystem.Directory.Images + "sun.jpg")) {
        try {
            /*
            // Convert image to jpg
            const image = await sharp(FileSystem.Directory.Images + "sun.jpg")
                .resize({
                    width: 300
                })
                .jpeg()
                .toBuffer();
                */
            doc.image(FileSystem.Directory.Images + "sun.jpg", doc.page.width - 160, doc.y, { width: 100, continued: true });
            doc.text("", doc.x, doc.y);
        } catch (error) {
            console.log(error)
        }
    }

Your environment

  • pdfkit version: 0.13
  • Node version: 20.3.1
  • Browser version (if applicable): /
  • Operating System: Debian/Windows

sun

@gary-radical
Copy link

Can confirm having same issue on node 18.16.1.

@malte94
Copy link
Author

malte94 commented Aug 8, 2023

@gary-radical Maybe this could help you: sindresorhus/get-stream#52

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

2 participants