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
| Left | Left edge the titles start at. |
|---|---|
| Top | Baseline of the first entry. |
| Right | Right edge the page numbers are set against. |
| Bottom | The layout stops before this. |
| FirstIndex | Zero-based index of the first heading to draw. |
Return values
| Count | How many entries were drawn. |
|---|---|
| 0 | Nothing 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);