Skip to content

Layout: a running header that shows the title of the current chapter #603

Closed

Description

@Tim81

Problem

A running band can show the page number and the page count, and nothing else that depends on the content.
(origin/main 1c61fa6.)

// src/VellumPdf.Layout/Elements/RunningBand.cs
201:     public string Resolve(int pageNumber, int totalPages) =>
202:         Template
203:             .Replace("{page}", ...)
205:             .Replace("{pages}", ...)

Pass 1 of the renderer counts pages and records nothing else (src/VellumPdf.Layout/Rendering/DocumentRenderer.cs:382-391:
totalPages = CountPages(); only when a header or footer is set), which is #288. So a band has no way to learn
which heading is on or before the page.

Why it matters

A printed handbook is read by flipping to a chapter. A header with the chapter title orients the reader, and
the planning note for the handbook lists it as a quality item.

Scope

  • A template token for the title of the current chapter (for example {chapter}), resolved from the headings the
    position map (Layout: pass 1 counts pages but records no positions #288) records: the text of the most recent level-0 heading that starts on or before the page.
    Options the brief must pick between and document: the heading on the page versus the one in force at the page's
    top, and what a page before the first heading shows (empty text).
  • Resolved on the second pass. Pass 1 already runs whenever a header or footer is set (DocumentRenderer.cs:383), so
    the position recording is what is conditional: it runs only when a band uses the token, and a document without the
    token pays nothing extra for it.
  • The token joins {page} and {pages} as a known token for Layout: an unknown placeholder in a running band template is printed literally without a report #598's unknown-token report.
  • The band's text is measured and truncated as today (BandTruncations); a long chapter title is cut, not
    wrapped, and reported there.
  • Artifact tagging of the band stays as in Layout: artifacts are emitted with no property list #303.

Acceptance

  • A document with three level-0 headings over six pages, header {chapter}: each page shows the expected title
    (extract the header text of every page and compare to a table).
  • A page before the first heading shows no title and no literal {chapter}.
  • A document whose bands have no {chapter} skips the position recording (assert that the recorder is not invoked)
    and runs the same number of layout passes as before (count passes through the renderer's counters; no wall-clock
    assertion).
  • A chapter title with a character the band font lacks follows Kernel: a character missing from an embedded font is written as glyph 0 (.notdef) and the save reports nothing #592's reporting.
  • The test fails on origin/main 1c61fa6, proven by mutation.

Relates to

Activity

  1. added
    enhancement
    area/layout
    type/feature
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/layoutenhancementtype/feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions