Flow
What the sizing script does
1Measure
Find the space in the schedule box.
2Rows
Work out row heights for the schedule and side panels from that space.
3Text
Shrink text that spills out of a cell.
4Fill
Add blank chore rows so the box is full.
5Shrink page
Scale the whole page only if it is still too tall.
6Not checked
How it looks on real paper.
The staff schedule printout for the stores would not fit on one sheet, and I spent an evening merging agent changes until it mostly did.
The page is one big schedule table with two small side panels, for tips and chores. It has to print on one sheet, and it kept coming out a bit too tall. Each time I asked the agent to fix it, it came back with a new fixed number.
Fixed numbers that kept changing
Row heights got doubled, then halved the same evening. The schedule box changed height three different ways. Padding got trimmed twice. The side panels got tied to the schedule's height, then cut to half each. I merged more than a dozen of these changes.
Each number was a guess at something the browser can measure: how tall the content is and how tall the page is. A fixed row height only works for one number of rows. A height based on the window only works for one window, and a window is not paper.
The part that measures
The better part is a script that runs before printing. It measures the space in the schedule box and works out a row height from it. The side panels get their row height from the same math. Text that spills out of a cell gets shrunk, and the chore list gets blank rows so it fills its box.
Two ways to shrink the page
Later that night, two branches tried to fix the last bit of overflow. One added a style rule that always shrinks the whole page by a few percent. The other added a script step: compare the window height to the content height, and if the content is too tall, shrink the page by exactly that much. If it fits, clear the shrink.
Clearing the script's shrink removes only the script's value. The stylesheet's rule is still there.
If both had stayed, the fixed rule would have come back every time the page already fit, and that page would print smaller and narrower than it should.
The merge
The fixed rule merged first. The measuring one merged a few minutes later, and that merge dropped the fixed rule completely. I can't tell you if that was a choice or luck. Either way, the page ended up with one thing in charge of its size.
What still bugs me is that the script measures the screen window, not the paper. None of that night's changes checks it against a real print preview.