Repository navigation
feat(html): render the later pages of a pdf on demand - #1257
Merged
Merged
Conversation
This is level 3 for a pdf, option B of `lazy-loading.md` decision 7. With `HtmlConfig::lazy_loading`, the document renders its first page. Each later page is an empty page box that loads `pdf-pages/<n>.js`, a render of that page alone: a `<style>` with its rules, and the content of its page box. - A page rendered alone suffixes its class, face and def names with its number. Its rules state their class three times, because the `.fvN` rule that every script states again comes later in the document. - The fonts that the pages and their forms state are numbered for the whole service and linked as `pdf-fonts/<n>.ttf`. The dual layer re-encodes a font to the PUA range only, so one file serves every page. A script carries its images inline. - The single layer keeps every page in the document, because it re-encodes a font for the runs it meets. On `Core_v5.1.pdf` (2985 pages): - The HTTP server answers the document after 0.5 s, not 5.4 s, and a page after 3 to 6 ms. - `document.html` is 1.4 MB, not 127 MB. - Writing it takes 138 MB, not 761 MB. - Screenshots at the start, the middle and nine tenths of the document are the same to the pixel as before. With the default config the output does not change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017QtawyvLP2SCnoBtnVfFed
clang-tidy 18 in CI refused the loop that collects the page sizes (performance-inefficient-vector-operation) and the empty class callback that took a string by value (performance-unnecessary-value-param). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHNzLmVv1mFWfPitHASucN
"after the first one at a time" read as one page after the other, and "every page in the page" used one word for two things. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHNzLmVv1mFWfPitHASucN
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHNzLmVv1mFWfPitHASucN
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.
Refs #764.
Summary
This is level 3 for a pdf: option B of
docs/design/lazy-loading.mddecision 7 (#1256). WithHtmlConfig::lazy_loading, the combined document renders its first page only. Each later page is an empty page box that loadspdf-pages/<n>.js, a render of that page alone.<style>with its page's rules, and the content of its page box. The placeholder already is the page box, with its size,page:,id="pN"anddata-odr-page. Soodr.chunks.fillworks as it does for text, and an internal#pNlink still lands.StyleRegistry::set_suffix,SubstituteFontFaces):x0_12,odr-s1_12..fvNrule of its fonts again, and later in the document. So in a document that loads its pages, the registry rules state their class three times (Rank::replaces_inline). Without that, a later page's.fvN{color:#000}turned an earlier page's blue link text black. A screenshot comparison caught this.pdf-fonts/<n>.ttf, whichbring_offlinewrites and the server serves.editing.js. So no pins move.Measured on
Core_v5.1.pdf(2,985 pages):document.htmlfile://Screenshots at 0, 30%, 50% and 90% of the document match the full render to the pixel, from
file://and over HTTP.Test
html.a_pdf_loads_its_later_pagescoversopendocument-app-website.pdf(8 pages):Review fixes
🤖 Generated with Claude Code