Skip to content

refactor(pdfkit): align object.js, outline.js and reference.js with upstream - #3482

Merged
diegomura merged 1 commit into
masterfrom
diegomura/pdfkit-upstream-sync
Aug 9, 2026
Merged

refactor(pdfkit): align object.js, outline.js and reference.js with upstream#3482
diegomura merged 1 commit into
masterfrom
diegomura/pdfkit-upstream-sync

Conversation

@diegomura

Copy link
Copy Markdown
Owner

Replaces all three files with foliojs/pdfkit master, byte-identical.

reference.js was the outlier — the fork still carried the pre-ES6 stream.Writable version with an async zlib.createDeflate, while upstream has buffered chunks and deflated synchronously in finalize() since 2017; nothing pipes into a ref or listens on it, document.js was already identical to upstream, and browserify-zlib exports deflateSync for the browser build, so the only observable change is that compressed objects are now emitted in call order rather than deferred to the end of the file (verified pixel-identical output before/after).

object.js is coupled to that (its instanceof PDFAbstractReference check only works once PDFReference extends it) and fixes a real bug: the old chain matched instanceof PDFNameTree, but PDFNumberTree extends PDFTree, so it fell through to the [object Object] branch and tagged PDFs emitted /ParentTree << /_items << /0 [10 0 R] >> /limits true >> instead of /ParentTree << /Nums [ 0 [10 0 R] ] >>.

outline.js had already been upstreamed, custom fork markers and all; what was left is DEFAULT_OPTIONS.fit and pageNumber != null vs !== null, neither of which reaches react-pdf since addBookmarks always passes an explicit options object with a numeric pageNumber.

Full test suite passes (2261 tests, 218 files), including the renderer visual snapshots.

🤖 Generated with Claude Code

…pstream

Replace all three with foliojs/pdfkit master, byte-identical.

reference.js was the outlier: the fork still carried the pre-ES6
stream.Writable version with an async zlib.createDeflate, while upstream
has buffered chunks and deflated synchronously in finalize() since 2017.
Nothing pipes into a ref or listens on it, document.js is already
identical to upstream and its _waiting/_ended bookkeeping works either
way, and browserify-zlib exports deflateSync for the browser build. The
only observable change is that compressed objects are now emitted in
call order instead of being deferred to the end of the file.

object.js is coupled to that: its instanceof PDFAbstractReference check
only works once PDFReference extends it instead of stream.Writable. It
also fixes a real bug. The old chain matched instanceof PDFNameTree, but
PDFNumberTree extends PDFTree, so it fell through to the [object Object]
branch and serialized its own internals. Tagged PDFs emitted
/ParentTree << /_items << /0 [10 0 R] >> /limits true >> instead of
/ParentTree << /Nums [ 0 [10 0 R] ] >>.

outline.js had already been upstreamed, custom fork markers and all.
What was left is DEFAULT_OPTIONS.fit and pageNumber != null vs !== null,
neither of which reaches react-pdf: addBookmarks always passes an
explicit options object with a numeric pageNumber, so DEFAULT_OPTIONS is
dead for us.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 483fa9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@react-pdf/pdfkit Patch
@react-pdf/font Patch
@react-pdf/renderer Patch
@react-pdf/types Patch
@react-pdf/math Patch
@react-pdf/mermaid Patch
next-14 Patch
next-15 Patch
@react-pdf/vite-example Patch
@react-pdf/layout Patch
@react-pdf/render Patch
@react-pdf/stylesheet Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@diegomura
diegomura merged commit ded9cdc into master Aug 9, 2026
8 of 14 checks passed
@diegomura
diegomura deleted the diegomura/pdfkit-upstream-sync branch August 9, 2026 22:43
@github-actions github-actions Bot mentioned this pull request Aug 9, 2026
exoego added a commit to exoego/react-pdf-renderer that referenced this pull request Aug 9, 2026
…gn-reference

Upstream already landed the identical reference.js alignment in diegomura#3482, so that
part of this branch is now a no-op. Resolved the remaining conflicts in favor of
master's new build layout (document.node.js and document.browser.js entry
points, standard-fonts output, no json plugin) while keeping this branch's
switch from rollup-plugin-polyfill-node to node-stdlib-browser.
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

Successfully merging this pull request may close these issues.

1 participant