Skip to content

Layout: a page-split element emits one structure element per fragment #285

Open

Description

@Tim81

This is a defect in output shipping today, not new work.

DocumentRenderer splits an element that does not fit: LayoutResult.Partial(occupied, split, overflow) (LayoutResult.cs:51) returns two renderers, and each is drawn separately. Meanwhile
ParagraphRenderer.cs:214 creates the structure element inside Draw:

var elem = new PdfStructElem(StructType) { Mcid = mcid };

So a paragraph that crosses a page break produces two P structure elements, not one.
TableRenderer.cs:147 does the same with tableElem = new PdfStructElem("Table"), so a table spanning
pages produces two Table elements.

Why it matters

PDF/UA-2 §8.2.2 forbids exactly this, and uses exactly this example:

Real content that is typically represented by a single semantic structure element with intrinsic
semantics shall not be represented by several such structure elements of the same structure type.

with the specification's own illustrations being one Table for a table spanning pages and one P for
a paragraph spanning pages or columns.

PDF/UA-1 does not state the rule this explicitly, which is presumably why the ua1 oracle passes
today. It will not pass ua2, and more importantly the output is wrong for a screen-reader user
regardless of which profile is being claimed: a paragraph read as two paragraphs is a real defect.

The fix changes the renderer contract

The structure element must be owned by the logical element and shared across its fragments, rather
than created per Draw call. That means:

  • an element's structure element is created once, at the point the element is laid out;
  • each fragment contributes its own MCID to that one element — a structure element can reference
    content on several pages through /K entries with /Pg;
  • StampStructElemPage (DrawContext) currently stamps one page onto one element, which is the
    single-page assumption made concrete and will need to become per-MCID.

Every renderer that creates structure elements is affected: ParagraphRenderer, TableRenderer,
ListRenderer, LayoutImageRenderer, PieChartRenderer.

Acceptance

  • A paragraph spanning a page break produces one P element with content items on both pages.
  • A table spanning a page break produces one Table.
  • A list spanning a page break produces one L, with the LI that straddles the break also intact.
  • veraPDF ua1 stays green, and the fixture is reusable for ua2 in v2.12.
  • The structure tree is asserted directly, not inferred from the oracle passing.

Relates to

Activity

  1. added
    area/layout
    bug
    on Aug 29, 2026
  2. Tim81 commented on Nov 18, 2026

    @Tim81
    OwnerAuthor

    Adds current line numbers, the split-LI-without-Lbl detail and measured proof. The list case and the direct
    structure-tree assertion are already in this issue's acceptance.

    The line numbers in the description have moved. On origin/main 1c61fa6 the per-fragment elements are created at:

    • paragraph: ParagraphRenderer.cs:328 (var elem = new PdfStructElem(StructType) { Mcid = mcid };), once per Draw;
    • table: TableRenderer.cs:224-226 (tableElem = new PdfStructElem("Table")), once per Draw;
    • list: ListRenderer.cs:200-202 (listElem = new PdfStructElem("L")). The item that was split gets a new LI
      without a Lbl on the continuation page (:211 sets isContinuation, :226-236 builds LI, and the Lbl only
      if (!isContinuation)).

    For the list case in the acceptance: a list over a page break gives two L elements, and the split item gives two
    LI elements, the second without Lbl.

    Measured in the 2026-11-16 handbook research on VellumPdf 2.3.3: a 90-row table became five Table elements
    (pages 1 to 5); the last filler paragraph became P mcid=13 pg=5 and P mcid=0 pg=6; a 158-page document with 20
    split tables passed veraPDF ua1 and the library's preflight.

    Why the fix needs a Kernel change first: PdfStructElem has one Page and one Mcid (PdfStructureTree.cs:18,
    :24), /K is either an MCID or an array of children (:260-273), and the ParentTree is built per page from the
    elements on that page (:168-215). DrawContext.StampStructElemPage stamps one page on one element
    (DrawContext.cs:318-322). A multi-page element needs mixed kids with a per-kid page: #604.

    Details to add to the acceptance:

    Dependent items: #582 (repeated header rows) and #589 (empty cells) assume this lands first.

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/layoutbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions