The print preview leaves writing space short by the margins of hidden headers, footers and solutions

Aperta Adatta ai principianti
#3,329 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
devtools, frontend

Direzione di ricerca

Inizia da getElementTotalHeight() in js/src/pretext-printouts.js, quindi segui i suoi sette chiamanti, in particolare adjustWorkspaceToFitPage() e measureRows(). Riproduci l’area di scrittura troppo corta usando l’articolo di esempio in headless Chromium, su carta Letter e con intestazioni e piè di pagina disattivati. Il lavoro è terminato quando gli elementi nascosti non contribuiscono più in modo errato ai margini, le interruzioni di pagina restano adeguate e le stampe indicate hanno lo spazio di scrittura previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

@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

Lingua principale
XSLT
Stelle
466
Fork
251
Merge medio
4m
PR unite (30g)
13

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PreTeXtBook/pretext

Tutte le issue di PreTeXtBook/pretext

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.