Skip to content

fix(render): specify the left coordinate in named destinations so internal links navigate in macOS Preview - #3460

Open
benbowler wants to merge 1 commit into
diegomura:masterfrom
benbowler:fix/named-destination-left-coordinate
Open

fix(render): specify the left coordinate in named destinations so internal links navigate in macOS Preview#3460
benbowler wants to merge 1 commit into
diegomura:masterfrom
benbowler:fix/named-destination-left-coordinate

Conversation

@benbowler

@benbowler benbowler commented Jul 29, 2026

Copy link
Copy Markdown

Fixes #3461.

setDestination currently registers named destinations as /XYZ null <top> null. Apple's PDFKit (which powers Preview and any macOS/iOS app embedding PDFView) discards the destination's top coordinate when the left coordinate is unspecified, and simply navigates to the top of the target page. On single-page documents this makes every internal <Link src="#id"> appear completely dead.

This PR passes the node's box.left (falling back to 0) instead of null, producing /XYZ 0 <top> null: the same explicit form Acrobat writes. Verified with a headless PDFView harness: with null left the view does not move; with a specified left it scrolls to the exact destination. Chrome (PDFium), Firefox (pdf.js), Edge and Acrobat resolve both forms, so behaviour there is unchanged.

Includes updated unit tests and a changeset.

Context: found while debugging Site Kit by Google (react-pdf powers its dashboard PDF export), where section links in the generated report worked in Chrome, Firefox, Edge and Acrobat but were dead in Apple Preview: google/site-kit-wp#13212. Site Kit currently ships this fix as a patch-package patch (google/site-kit-wp#13225) and will drop it once a release containing this change is adopted.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ee082a1

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

This PR includes changesets to release 7 packages
Name Type
@react-pdf/render Patch
@react-pdf/renderer Patch
@react-pdf/math Patch
@react-pdf/mermaid Patch
next-14 Patch
next-15 Patch
@react-pdf/vite-example 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

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.

Internal links do not navigate in macOS Preview (named destinations emit an unspecified left coordinate)

1 participant