Skip to content

fix(writers): keep the same PDF version#1747

Open
Velmisov wants to merge 1 commit intoHopding:masterfrom
Velmisov:fix/keep-pdf-version
Open

fix(writers): keep the same PDF version#1747
Velmisov wants to merge 1 commit intoHopding:masterfrom
Velmisov:fix/keep-pdf-version

Conversation

@Velmisov
Copy link
Copy Markdown

@Velmisov Velmisov commented Jun 6, 2025

What?

Keep the same PDF version after loading and saving.

Why?

The PDF version changes after loading and saving.

How?

Get a header from a context instead of creating a new header.

Testing?

New Dependencies?

No

Screenshots

Suggested Reading?

Anything Else?

Checklist

  • I read CONTRIBUTING.md.
  • I read MAINTAINERSHIP.md#pull-requests.
  • I added/updated unit tests for my changes.
  • I added/updated integration tests for my changes.
  • I ran the integration tests.
  • I tested my changes in Node, Deno, and the browser.
  • I viewed documents produced with my changes in Adobe Acrobat, Foxit Reader, Firefox, and Chrome.
  • I added/updated doc comments for any new/modified public APIs.
  • My changes work for both new and existing PDF files.
  • I ran the linter on my changes.

@Velmisov Velmisov marked this pull request as ready for review June 6, 2025 10:01
folknor added a commit to folknor/pdf-lib that referenced this pull request Jan 29, 2026
Both PDFWriter and PDFStreamWriter hardcoded PDFHeader.forVersion(1, 7),
discarding the original PDF version parsed from the input file. This
caused PDFs with other versions (e.g. 1.4, 2.0) to be rewritten as
1.7, which could cause compatibility issues with strict readers.

Now uses context.header which preserves the parsed version.

Fixes Hopding/pdf-lib#1747

Coded by an LLM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant