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

Error embeding png #72

Open
2 tasks done
deathemperor opened this issue Oct 16, 2024 · 6 comments
Open
2 tasks done

Error embeding png #72

deathemperor opened this issue Oct 16, 2024 · 6 comments
Labels
bug Something isn't working needs-triage

Comments

@deathemperor
Copy link

What were you trying to do?

Embed png file into page

How did you attempt to do it?

const pdf = await PDFDocument.create();
const image = await pdf.embedPng(file);
const page = pdf.addPage([image.width, image.height]);

file is buffer, attached

bc891fa0-9cef-4165-89b3-02356b97b5a5

What actually happened?

2024-10-17 01:54:06.455 ERROR Invoke Error {"errorType":"TypeError","errorMessage":"dV.default.decode is not a function","stack":["TypeError: dV.default.decode is not a function"," at new PNG (/node_modules/@cantoo/pdf-lib/src/utils/png.ts:51:23)"," at pngData (/node_modules/@cantoo/pdf-lib/src/utils/png.ts:41:42)"," at Function.for (/node_modules/@cantoo/pdf-lib/src/core/embedders/PngEmbedder.ts:12:21)"," at a.embedPng (/node_modules/@cantoo/pdf-lib/src/api/PDFDocument.ts:1113:40)"

What did you expect to happen?

added successfully

How can we reproduce the issue?

const pdf = await PDFDocument.create();
const image = await pdf.embedPng(file);
const page = pdf.addPage([image.width, image.height]);

file is buffer, attached

Version

2.2.3

What environment are you running pdf-lib in?

Node

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

@deathemperor deathemperor added bug Something isn't working needs-triage labels Oct 16, 2024
@deathemperor
Copy link
Author

strangely enough it doesn't happen running with bun, only nodejs (v20, v22)

@deathemperor
Copy link
Author

original pdf-lib doesn't encounter this issue FYI

@Sharcoux
Copy link
Collaborator

Which version of Node did you use?

@deathemperor
Copy link
Author

Which version of Node did you use?

happens on node 18, 20, and 22

@benconnito
Copy link

looks to be happening when using esm ...

import UPNG from '@pdf-lib/upng';

is an object with default

image

@Sharcoux
Copy link
Collaborator

Sharcoux commented Dec 3, 2024

To solve the issue, we would probably need to solve this problem:

#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants