fix(html): print a sheet onto the page, without our ruler - #817
Merged
Conversation
andiwand
force-pushed
the
fix/print-a-sheet-onto-the-page
branch
from
September 5, 2026 20:22
046850a to
ee58f5c
Compare
A spreadsheet is laid out at the width the file states — one `<col>` per column carrying the document's own width, under `table-layout:fixed`. Paper cannot scroll, so what did not fit was cut off along the right edge once the browser's own shrink-to-fit gave up: silent, bounded, and different per browser and print path. A phone print has no scale control to correct it with, which is where it was reported. `@media print` fits the sheet to the page instead, and leaves off the row and column ruler, which is ours rather than the file's and took about a centimetre a page has none of to spare. The screen view is untouched. Towards #816, opendocument-app/OpenDocument.droid#644. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fp26La4hFAu9VRMHPjKmXd
andiwand
force-pushed
the
fix/print-a-sheet-onto-the-page
branch
from
September 5, 2026 20:22
ee58f5c to
3813aaa
Compare
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.
🤖 Generated with Claude Code
The first, self-contained part of #816: the sheet is fitted to the paper it is printed on, and the ruler stays off it. Print only — no public API, no parser, no change to what the screen shows.
Why
translate_sheetwrites one<col>per column carrying the document's own width aswidthandmin-width, undertable-layout:fixed, so the table is exactly as wide as the file says. On screen that is right, and the viewport fit hides it. On paper nothing relates it to the page: the only@media printrule we ship pins the zoom back to actual size, correctly, and nothing fits the sheet afterwards. What is left is the browser's own shrink-to-fit — silent when it gives up, bounded, and different per browser and print path. A desktop dialog has a scale control on top of it; the Android print framework offers the user none, which is the asymmetry in opendocument-app/OpenDocument.droid#644.The ruler makes it worse: the gutter and the
<thead>of column letters are ours, not the file's, and a spreadsheet application prints neither.What it does
max-widthfits the sheet to the page box;!importantis what beats the width written inline per column. A sheet narrower than the page is untouched —max-widthonly bites above it.display:none: removing those cells takes them out of their rows and shifts every column one to the left, which I measured before settling on this. The cells statevisibility:collapsetoo, for a browser that collapses no column.Measured
Chrome headless
--print-to-pdf, Letter, text recovered withgs -sDEVICE=txtwrite. A 12-column × 1.5in sheet rendered bytranslatefrom a flat ODF:odr-public/ods/file_example_ODS_10.ods(7.50in incl. ruler, fits today): identical printed text before and after except the ruler's letters and numbers — no cell gained or lost.Across widths, on the same markup:
So dropping the ruler alone buys about one column of width and is not a fix by itself, as #816 says.
What it does not do
The fit is a shrink, not what a spreadsheet application does. Columns narrow toward, but not below, their content, so relative widths compress rather than scale: at 8 × 3in on Letter every column comes out equal. A very wide sheet prints small rather than paginating column-wise. Honouring the file's page style — paper, orientation, fit-to-pages, print ranges, repeated headers — needs
Sheet::page_layout(), which does not exist, and column-wise pagination needs slices html cannot express for a table. #816 stays open for that decision.visibility:collapseon a<col>is verified in Blink; WebKit is the untested half, and thewidth:0plus the cells' ownvisibilityare the fallback for a browser that only hides the column.Reference output
Unchanged, and no pin moves. The suite renders with
embed_shipped_resources = false, so the stylesheet lives inresources/— which the CI comparison does not cover; it comparesoutput/, and a print-only rule moves no screen pixel there.Test
html.a_printed_sheet_drops_the_ruler_and_fits_the_pagerenders an.odsand checks the print rules are emitted and the screen ones — the inline column widths,table-layout:fixed, the ruler markup — are still there.