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

Image objects corrupted while saving/cloning an encrypted pdf #69

Open
2 tasks done
carlosrafp opened this issue Sep 9, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@carlosrafp
Copy link

What were you trying to do?

The library is able to open the pdf file but after saving it corrupts some images/objects changing color.

const pdf = await PDFDocument.load(buffer, { password: '' });
const bytes = await pdf.save();

Input pdf:
laudo.pdf

The output/cloned pdf displays wrong color of logo and the signature images:
cloned.pdf

Checking the generated pdf on qdpf shows:

PDF Version: 1.7
File is not encrypted
File is not linearized
WARNING: cloned.pdf object stream 62 (object 14 0, offset 2243): unknown token while reading object; treating as string
WARNING: cloned.pdf object stream 62 (object 14 0, offset 2252): unexpected )
WARNING: cloned.pdf object stream 62 (object 14 0, offset 2264): EOF while reading token
WARNING: cloned.pdf object stream 62 (object 14 0, offset 8104): parse error while reading object
WARNING: cloned.pdf object stream 62 (object 14 0, offset 8104): unexpected EOF
WARNING: cloned.pdf object stream 62 (object 32 0, offset 7262): EOF while reading token
WARNING: cloned.pdf object stream 62 (object 32 0, offset 8104): parse error while reading object
WARNING: cloned.pdf object stream 62 (object 32 0, offset 8104): unexpected EOF
WARNING: cloned.pdf object stream 62 (object 33 0, offset 7431): EOF while reading token
WARNING: cloned.pdf object stream 62 (object 33 0, offset 8104): parse error while reading object
WARNING: cloned.pdf object stream 62 (object 33 0, offset 8104): unexpected EOF
WARNING: cloned.pdf object stream 62 (object 34 0, offset 7609): EOF while reading token
WARNING: cloned.pdf object stream 62 (object 34 0, offset 8104): parse error while reading object
WARNING: cloned.pdf object stream 62 (object 34 0, offset 8104): unexpected EOF
WARNING: cloned.pdf object stream 62 (object 61 0, offset 8027): EOF while reading token
WARNING: cloned.pdf object stream 62 (object 61 0, offset 8104): parse error while reading object
WARNING: cloned.pdf object stream 62 (object 61 0, offset 8104): unexpected EOF
qpdf: operation succeeded with warnings

How did you attempt to do it?

  1. Load the provided PDF document with an empty password option
  2. Save it

What actually happened?

Output pdf contains corrupted image objects, that displays wrong color

What did you expect to happen?

The PDF to be saved properly.

How can we reproduce the issue?

Use the steps above.

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

@carlosrafp carlosrafp added bug Something isn't working needs-triage labels Sep 9, 2024
@Sharcoux Sharcoux added help wanted Extra attention is needed and removed needs-triage labels Sep 9, 2024
@Sharcoux
Copy link
Collaborator

Sharcoux commented Oct 7, 2024

We noticed this, but we didn't have time to solve so far. If anyone has time to spend on this, be my guest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants