type TSToc = class uses TSPdfEnumerations; public function Create(ppr: PPrUnitDecorator; rect: array of real; page: TSPage; x: real; y: real; font: PdfFont); function LinkAnnot(dst: PdfDestination); function AddPageNumber(page: TSPage); private ppr_: PPrUnitDecorator; rect_: array of real; font_: PdfFont; [weakref]tspage_: TSPage; x_; y_; end; function TSToc.Create(ppr: PPrUnitDecorator; rect: array of real; page: TSPage; x: real; y: real; font: PdfFont); begin ppr_ := ppr; rect_ := rect; tspage_ := page; x_ := x; y_ := y; font_ := font; end; function TSToc.LinkAnnot(dst: PdfDestination); begin annot := tspage_.PdfPage.CreateLinkAnnot(rect_, dst); annot.LinkAnnotSetHighlightMode(TSPdfEnumerations.ANNOT_NO_HIGHTLIGHT); annot.LinkAnnotSetBorderStyle(0, 0, 0); end; function TSToc.AddPageNumber(page: TSPage); begin number := tostring(page.Number); symbol := "."; tspage_.PdfPage.SetFontAndSize(font_, ppr_.RPr.Sz.Val); w := tspage_.PdfPage.TextWidth(symbol); number_sz := tspage_.PdfPage.TextWidth(number); x := rect_[2] - number_sz; tspage_.PdfPage.BeginText(); tspage_.PdfPage.TextOut(x, y_, number); tspage_.PdfPage.EndText(); while x_ < x - w do begin tspage_.PdfPage.BeginText(); tspage_.PdfPage.TextOut(x_, y_, symbol); tspage_.PdfPage.EndText(); x_ += w; end end;