Scale layout to a wide viewport, then fit the print column - #1
Merged
Conversation
RFC 9110's HTML edition (and, to a lesser degree, every other corpus page) rendered technically correctly but page-bloated: laying out directly at the print column's own width (~642px for A4/20mm) sits below the breakpoint a real desktop-oriented page relies on to drop a fixed-width sidebar, so the sidebar just squeezed the prose into a sliver instead. Options.ViewportPx (default 1024px) now sets the width a page is laid out against; Export scales the whole result down to fit the print column, same idea as a browser print dialog's "shrink to fit". Corpus effect: RFC 9110 428->120 pages, pkg.go.dev/net/http 86->49, Wikipedia 34->18, extracted text length unchanged (a density change, not a content change) — see corpus/CORPUS.md for the full before/after table. Also split the former single html2pdf.go into atoms.go (pagination), fonts.go (font loading/selection) and render.go (the PDF paint pass), each with its own package-level doc comment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Exportnow lays out atOptions.ViewportPx(default 1024px) and scales the result to fit the print column, instead of laying out directly at the print column's own (~642px) width.pkg.go.dev/net/http86→49, Wikipedia 34→18 — seecorpus/CORPUS.mdfor the full before/after across all 8 corpus pages. Extracted text length is unchanged on every page (density change, not a content change).html2pdf.gointoatoms.go(pagination),fonts.go(font loading/selection) andrender.go(the PDF paint pass), each with its own doc comment.Test plan
go test ./...green (both modules)gofmt -l ./go vet ./...cleancorpus/out/)🤖 Generated with Claude Code