支持目录
This commit is contained in:
+3
-2
@@ -1,5 +1,6 @@
|
||||
type TSPage = class
|
||||
public
|
||||
PdfPage;
|
||||
Index;
|
||||
PdfPage: PdfPage;
|
||||
Index: integer;
|
||||
Number: integer; // 页码
|
||||
end;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
type TSPoint = class
|
||||
function Create();
|
||||
begin
|
||||
{self.}X := 0;
|
||||
{self.}Y := 0;
|
||||
end
|
||||
X: real;
|
||||
Y: real;
|
||||
end;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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);
|
||||
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;
|
||||
Reference in New Issue
Block a user