The print preview leaves writing space short by the margins of hidden headers, footers and solutions
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
Research direction
Start with getElementTotalHeight() in js/src/pretext-printouts.js, then trace its seven callers, especially adjustWorkspaceToFitPage() and measureRows(). Reproduce the short writing area using the sample article in headless Chromium on Letter paper with headers and footers off. Done when hidden elements no longer contribute margins incorrectly, page breaks remain appropriate, and the listed printouts have the expected writing space.
Written by the indexing model from the issue text.
Description
@oscarlevin, this turned up while reviewing #3327, but it is on master and is not from that pull request.
The print preview stretches writing space so that each sheet is full, but every sheet with writing space stops about 30 pixels (0.3 inch) short, and about 15 pixels more for each hint, answer or solution hidden on that sheet.
getElementTotalHeight(), in js/src/pretext-printouts.js, adds an element's top and bottom margins as getComputedStyle() reports them, and those are not zero for an element that is not displayed. adjustWorkspaceToFitPage() adds this up over every child of a sheet, and so counts:
- the header and footer bands, which every sheet carries and which stay hidden unless the reader switches them on: a bottom margin of 14.67 pixels on the header and a top margin of 14.67 pixels on the footer;
- each hidden hint, answer or solution row: about 15 pixels, 22 for some.
The room it gives the writing space is short by that total, and the sheet ends with that much left blank at the foot. With headers and footers switched on, the bands are displayed and their margins are real, so they are counted correctly then.
measureRows() takes row heights from the same function, so the page-break planner is also charged the margins of a hidden row, though the comment there says such a row has height 0. The function has seven callers in all.
Measured on master (06a9be75b) with the sample article in headless Chromium, on Letter paper with headers and footers off: the blank room at the foot of a sheet, and the same with one line added at the top of getElementTotalHeight(), if (style.display === 'none') return 0;. The line moves no page break in these printouts. All figures are in pixels.
| printout | hidden rows on the sheet | blank at the foot, master | with the line |
|---|---|---|---|
worksheet-workspace, sheets 1 to 4 |
0 | 38, 30, 31, 31 | 8, 1, 1, 1 |
worksheet-testing, sheet 1 |
1 | 52 | 8 |
worksheet-activity-with-task |
1 | 52 | 8 |
project-printout-tasks |
1 | 53 | 9 |
worksheet-geometric-prelude-pages, sheet 2 |
1 | 71 | 19 |
The line is a test, not a proposed fix; the other callers may need a different answer. On the worksheet that #3327 adds, where every task has a solution and the solutions start hidden, a sheet ends up as much as 103 pixels short.
Claude Opus 5.5, acting as a coding assistant for Rob Beezer
- Dominant language
- XSLT
- Stars
- 466
- Forks
- 251
- Avg merge
- 4m
- Merged PRs (30d)
- 13
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PreTeXtBook/pretext
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
PreTeXtBook/pretext#3305 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PreTeXtBook/pretext#3297 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
PreTeXtBook/pretext#3285 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PreTeXtBook/pretext#3283 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
PreTeXtBook/pretext#3272 ·
Maintainers usually reply within 1 day
All issues in PreTeXtBook/pretext
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
nightscout/AndroidAPS#5600 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
ScoopInstaller/Extras#19404 ·
Maintainers usually reply within 1 day
-
agent good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
Viox-Development/Artificial-Logic-and-Intelligence-Computation-Engine#250 ·
Maintainers usually reply within 1 day
-
area: batch
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
inabagumi/shinju-date#7294 ·
Maintainers usually reply within 1 day