Fix two-page PDF export on macOS#3
Closed
yihui wants to merge 2 commits into
Closed
Conversation
scrollHeight returns an integer floor of the actual content height; on macOS, font metrics (San Francisco) can make the rendered table 0.x px taller than the measured value, causing the PDF to spill onto a second page. Adding 1px to the @page height absorbs this sub-pixel difference without visibly enlarging the crop. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lt_measure() reads body.scrollWidth, which is the integer floor of the table's fractional natural (max-content) width. lt_export() then pins the body to that floored width for the PDF pass. Being a sub-pixel narrower than the content, a cell would wrap, growing the table taller than the measured height and pushing the PDF onto a second page. This reproduced on macOS (Google Chrome) but not Linux (Chromium), because their font metrics round differently. Fix: add 1px to the measured width so the body is never narrower than the content and never re-wraps. Replaces the earlier 1px height buffer (wrong axis). Adds a regression test exporting a wide, long-labelled table to a single-page PDF. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lt_export()to PDF produces a two-page file on macOS GHA runners(e.g.
examples/01-lt.pdf), though it is a single page on Linux. The1px
@pageheight buffer (a972a61) did not resolve it.This PR temporarily replaces the site build with a debug script
(
debug-pdf.R) that runs onmacos-latestto capture the measuredscreen-media size vs the print-media height, page counts across several
@pageheight buffers, and the resulting MediaBox. Once the root causeis pinned down, the fix will replace the debug scaffolding.
Not ready for merge — debug scaffolding present.
🤖 Generated with Claude Code