修复标题在前,目录在后,页码无法定位

This commit is contained in:
csh 2024-07-29 15:43:45 +08:00
parent d14de26d58
commit e5dfdeadc0
1 changed files with 12 additions and 1 deletions

View File

@ -41,6 +41,7 @@ private
point_: TSPoint; // 定位坐标点 point_: TSPoint; // 定位坐标点
page_array_: array of TSPage; page_array_: array of TSPage;
toc_array_: tableArray; toc_array_: tableArray;
toc_unmacthed_array_: tableArray;
end; end;
type TSPoint = class type TSPoint = class
@ -65,6 +66,7 @@ begin
point_ := new TSPoint(); point_ := new TSPoint();
page_array_ := array(); page_array_ := array();
toc_array_ := array(); toc_array_ := array();
toc_unmacthed_array_ := array();
end; end;
function TSDocxToPdf.Destroy(); function TSDocxToPdf.Destroy();
@ -292,12 +294,21 @@ function TSDocxToPdf.AddToc(anchor: string; toc: TSToc);
begin begin
if ifarray(toc_array_[anchor]) then toc_array_[anchor] union= array(toc); if ifarray(toc_array_[anchor]) then toc_array_[anchor] union= array(toc);
else toc_array_[anchor] := array(toc); else toc_array_[anchor] := array(toc);
if toc_unmacthed_array_[anchor] then
begin
{self.}LinkToToc(anchor, toc_unmacthed_array_[anchor]);
toc_unmacthed_array_[anchor] := nil;
end
end; end;
function TSDocxToPdf.LinkToToc(anchor: string; page: TSPage); function TSDocxToPdf.LinkToToc(anchor: string; page: TSPage);
begin begin
arr := toc_array_[anchor]; arr := toc_array_[anchor];
if ifnil(arr) then return; if ifnil(arr) then
begin
toc_unmacthed_array_[anchor] := page;
return;
end
dst := page.PdfPage.CreateDestination(); dst := page.PdfPage.CreateDestination();
for _,toc in arr do for _,toc in arr do
toc.LinkAnnot(dst); toc.LinkAnnot(dst);