RegisterHeading

Page layout

Description

Records a heading on the selected page for a later table of contents.

Syntax

Delphi

Function TPDFlib.RegisterHeading(Level: Integer; Const Title: WideString): Integer;

Parameters

LevelNesting level, 1 for a top-level heading.
TitleThe text to list.

Return values

CountHow many headings are registered.
0The level or the title was empty, or no page is selected.

Remarks

The heading remembers where it points, not which page number it currently has. That is what lets the contents page be inserted in front of the finished body - which renumbers every page it refers to - without any entry or link needing to be fixed up.

Registrations belong to the document that was selected at the time. Opening another document leaves them in place but they no longer resolve, so a contents page can only be drawn into the document its headings came from.

Example

PDF.DrawText(72, 100, 'Chapter One');
PDF.RegisterHeading(1, 'Chapter One');

See also

RegisterHeadingEx, DrawTOC, PopulateOutlineFromHeadings