diff --git a/TSDocxToPdf.tsf b/TSDocxToPdf.tsf index 3e45426..2b2a99d 100644 --- a/TSDocxToPdf.tsf +++ b/TSDocxToPdf.tsf @@ -41,6 +41,7 @@ private point_: TSPoint; // 定位坐标点 page_array_: array of TSPage; toc_array_: tableArray; + toc_unmacthed_array_: tableArray; end; type TSPoint = class @@ -65,6 +66,7 @@ begin point_ := new TSPoint(); page_array_ := array(); toc_array_ := array(); + toc_unmacthed_array_ := array(); end; function TSDocxToPdf.Destroy(); @@ -292,12 +294,21 @@ function TSDocxToPdf.AddToc(anchor: string; toc: TSToc); begin if ifarray(toc_array_[anchor]) then toc_array_[anchor] union= 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; function TSDocxToPdf.LinkToToc(anchor: string; page: TSPage); begin 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(); for _,toc in arr do toc.LinkAnnot(dst);