Skip to content

fix(layout): draw a table whose every row is a header (#488) - #649

Merged
Tim81 merged 6 commits into
mainfrom
fix/table-all-header-rows
Nov 21, 2026
Merged

Tim81 merged 6 commits into
mainfrom
fix/table-all-header-rows

Conversation

@Tim81

@Tim81 Tim81 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Closes #488

What changed

The repeatable header is the leading run of header rows only when a row that is not a header follows
it. A table whose rows are all headers has no header to repeat, so TableRenderer lays out and draws
its rows as the body: each once, in order, split between rows like any other table. Each row is
still tagged TH with /Scope /Column, because Row.IsHeader decides that.

The change is in TableRenderer.FindHeaderRowIndices, which returns an empty list when the run
covers every row. Layout and Draw both read that list, so they agree by construction. Before, the
run covered every row, dataStartRow equalled the row count, the fit loop never ran and Layout
returned Nothing on any area, so Save threw the "too tall" InvalidOperationException.

XML docs rewritten to say so: TableRenderer (summary, remarks, constructor remarks, the Draw
IndexOutOfRangeException condition), Row.IsHeader, TableElement (class remarks, AddRow,
AddHeaderRow), Cell.RowSpan. The save-time InvalidOperationException tags for "every row is a
header" are removed because that case no longer throws. LayoutGen.RowHeaderShape now includes both
rows as headers, and its comment no longer excludes the shape.

Deliberate output and behaviour changes

  • Inputs that threw now save: an all-header table of any row count (measured: 1, 2, 3 and 30 rows).
  • TableRenderer.Layout returns Full or Partial for an all-header table, where 2.3.3 returned
    Nothing on every area. A caller's renderer that composes TableRenderer and skips Nothing now
    draws the table.
  • An all-header table with a non-finite cell background (NaN and +Infinity measured), table
    BorderColor (NaN) or table Margins (NaN) threw the "too tall" InvalidOperationException on
    2.3.3. It now throws the canvas's ArgumentException, the same as any table with data rows. One
    rule for all three; each is pinned in a test with the exact type.
  • TableRenderer.Draw called before Layout on a table with no repeatable header (no header row,
    or every row a header) draws nothing; a table with leading header rows and a row after them
    still throws IndexOutOfRangeException. Documented on Draw as a rule.

2.3.3 against this build

Probe: 300x600 page, 10 pt margins, one Helvetica 10 pt cell per row. Both assemblies printed:
VellumPdf.Layout.dll 2.3.3+1c61fa6... (2.3.3) and 2.3.3+b95d435... (this build).

Input 2.3.3 This build
H InvalidOperationException (too tall) saves, 1,551 B
HH InvalidOperationException saves, 1,565 B
HHH InvalidOperationException saves, 1,577 B
30 header rows InvalidOperationException saves, 2,146 B
HDD, DDD, HDH saves, 1,577 B each saves, 1,577 B each
one header row, NaN cell background InvalidOperationException ArgumentException (canvas)

The content of HHH, and of 1, 2, 3 and 29 header rows, equals the content of the same rows as data
rows byte for byte (AllHeaderRows_untagged_drawTheContentOfTheSameRowsAsDataRows).

Tests

tests/VellumPdf.Layout.Tests/TableAllHeaderRowsTests.cs, value-level: exact shown strings, baselines
(576 for the first row, 20 pt apart), per-page contents of 30 and 61 header rows (page 1 holds
r0..r28, page 2 holds r29 alone), a footer run (1/2, 2/2; the footer leaves room for 28 rows, so page 1 holds r0..r27 and page 2 holds r28 and r29), a RowSpan group
kept whole across the break, a group taller than the page still refused, HDD / HDH controls, no rows
still refused for no columns, start row past the end still Nothing, tagged HHH (3 TR, 3 TH,
3 /Scope /Column, 0 TD), a header run followed by 30 data rows and a trailing header row across two pages (page 2 is r0, r29, r30, r31), the exact no-columns message for no rows, H and HHH without cells, the save throwing for a start row past the end, the exception type for each of the NaN and +Infinity background, NaN BorderColor and NaN margin, and the Draw-before-Layout behaviour (HDD throws, HHH and DDD draw nothing, asserted on the page content).
Oracles: pdftotext on the 30-row file (every row once and in order, page break after r28); qpdf
12.4.2 --check and veraPDF 1.30.4 ua1 on tagged HHH in embedded DejaVu Sans, each after asserting
the fixture holds three /S /TH. PropertyTests.ValidDocument_rendersWithoutThrowing and
ValidDocument_placesNothingOutsideThePage pass with the widened generator.

Release, REQUIRE_ORACLES=1, REQUIRE_VERAPDF=1, after merging origin/main: VellumPdf.Layout.Tests
1,184 passed, 0 failed, 2 skipped (Linux-only pipe tests) on net10.0 and on net11.0. Release solution
build 0 warnings; dotnet format --verify-no-changes, eng/clean-room-check.ps1 and
generate-roadmap.py --check exit 0.

Mutations (each run in a detached worktree, Release, oracles required; rebuilt DLLs checked)

Mutant Failing tests (net10.0 and net11.0 alike)
M1 FindHeaderRowIndices returns the run for an all-header table (the old behaviour) 19 of 29 in TableAllHeaderRowsTests (every all-header test except the refusal and start-row ones, and both tests of a leading header run), Draw_beforeLayout_...(HHH), PropertyTests.ValidDocument_rendersWithoutThrowing, ValidDocument_placesNothingOutsideThePage
M2 empty list only for a one-row table (rows.Count == 1 ? [] : indices) 13 of 29: fitOnePage(HH), (HHH), both pagination tests, the footer test, the span test, the tagged tests, the oracle tests, the content-equality cases for 2, 3 and 29 rows, Draw_beforeLayout_...(HHH), both property tests
M3 if (!rows[i].IsHeader) return rows[^1].IsHeader ? [] : indices; (a table whose last row is a header has no repeatable header) HeaderRunWithATrailingHeaderRow_stillRepeats_acrossPages, and nothing else; the property tests pass. The test is the only guard against this mutant.

Not done

The repeatable header is the leading run of header rows only when a
row that is not a header follows it. With none, the run covered every
row, the fit loop never started and Layout gave up on any area, so
Save threw "too tall" for a table that was never too tall. Such a table
now lays out and draws as its own body, split between rows like any
other, each row still tagged TH.
Review round on the all-header table change: a multi-page trailing-header
case, the Layout outcome and the exception-type changes named in the
CHANGELOG, exact messages on the no-column refusals, Draw before Layout
asserted to draw nothing, and the touched comments wrapped to 100 columns.
@Tim81
Tim81 merged commit 1c3ac0e into main Nov 21, 2026
4 checks passed
@Tim81
Tim81 deleted the fix/table-all-header-rows branch November 26, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Layout: a table whose every row is a header refuses to render on a page with room to spare

1 participant