DrawTOC

Page layout

Description

Draws the registered headings as a table of contents on the selected page.

Syntax

Delphi

Function TPDFlib.DrawTOC(Left, Top, Right, Bottom: Double; FirstIndex: Integer): Integer;

Parameters

LeftLeft edge the titles start at.
TopBaseline of the first entry.
RightRight edge the page numbers are set against.
BottomThe layout stops before this.
FirstIndexZero-based index of the first heading to draw.

Return values

CountHow many entries were drawn.
0Nothing was drawn: no headings, an index past the end, or no room between Top and Bottom.

Remarks

Each entry is indented by its level, followed by a run of dots reaching across to the page number set against the right edge, with the whole row linking to the heading. The page number is resolved as the document stands when this is called, so it is correct even though the body was written before the contents page existed.

A list longer than the space given is drawn a page at a time: call again on the next page with FirstIndex advanced by the count already returned. MeasureTOC says how many pages will be needed.

Coordinates read top-down regardless of the origin in force, and the font, size and alignment are left as they were.

Example

Pages:= PDF.MeasureTOC(72, 100, 540, 700);
PDF.InsertPages(1, Pages);
PDF.SelectPage(1);
PDF.DrawTOC(72, 100, 540, 700, 0);

See also

MeasureTOC, RegisterHeading, InsertPages