Skip to content

Layout: a heading that splits across pages gets its bookmark at the page top #464

Closed

Description

@Tim81

HeadingRenderer's private constructor, the one used for the split half when a heading crosses a
page boundary, sets _heading and _inner and never assigns _occupied:

// Private constructor used by Split/Overflow path (inner already has StructType set).
private HeadingRenderer(Heading heading, ParagraphRenderer inner)
{
    _heading = heading;
    _inner = inner;
}

Layout assigns _occupied on this, not on the copy it returns, and Draw reads it:

ctx.AddOutlineEntry(_heading.ResolvedBookmarkTitle, _heading.Level, _occupied.Y);

So the split half draws with _occupied still at default, and the outline entry is registered at
layout Y 0, which is the top of the page rather than the point where the heading starts.

Measured

A 200x300pt page with EdgeInsets(10), a filler paragraph, then a heading, varying only the
heading's length so that it does or does not split:

Heading Pages Outline destination
short, fits 1 /Dest [2 0 R /XYZ 0 130 null]
long, splits 3 /Dest [4 0 R /XYZ 0 300 null]

130 is where the heading actually starts. 300 is the page height, so the second destination is the
top of the page.

A reader clicking that bookmark lands above the heading, at whatever content happens to precede it
on the page. The longer the run of content before a split heading, the further off the destination.

Not caused by #459

Pre-existing. DocumentRenderer has always drawn LayoutResult.SplitRenderer for a Partial
result, before and after pagination became iterative, so this behaves identically on 2.3.0.

It surfaced while reviewing #461, as the counterexample to a claim that drawing the split half
rather than the element itself is unobservable with built-in renderers. It is observable, through
the public Document and Heading API, and the shipped behaviour is the wrong one of the two.

Fix

Carry _occupied into the split copy, either through the private constructor or with an object
initialiser at the call site, the way ParagraphRenderer, ListRenderer and TableRenderer all
carry their own occupied area into theirs.

Acceptance

A heading that splits across a page boundary registers its outline destination at the Y it starts
at, asserted against the emitted /Dest, with a non-splitting heading as the control.
OutlineBookmarkTests currently never splits a heading.

Activity

  1. added
    bug
    area/layout
    on Sep 10, 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/layoutbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions