function GetLinkedAnnotationChain(AnnotIndex: Integer; Relationship: TPdfAnnotationRelationship; MaxDepth: Integer = 64): TPdfIntegerArray;
| AnnotIndex | Integer。当前页面上起始注释的从零开始的索引,范围 0 .. AnnotationCount - 1 |
| Relationship | TPdfAnnotationRelationship。parPopup 跟随 /Popup 条目;parInReplyTo 跟随 /IRT 回复条目 |
| MaxDepth | Integer。要跟随的最大链接数量。必须在 1 到 4096 之间,否则会引发 EPdfError。默认值为 64 |
| Result | TPdfIntegerArray。按访问顺序排列的链接注释的页面索引。当起始注释没有此类链接时为空 |
反复应用 GetLinkedAnnotationIndex:从起始注释开始,沿请求的关系前进到下一个注释,然后从那个注释再次前进,沿途收集每个索引。结果是对话的回复串或弹出式注释链,以简单的页面注释索引数组表示
遍历在三种情况下停止:当前注释没有后续链接、已访问链接数量达到 MaxDepth,或下一个索引会重新访问已经看过的注释(起始索引也算作已看过)。循环保护使该调用在 /IRT 条目成环的畸形文档上仍然安全
起始索引本身从不是结果的一部分 — 只有它指向的注释才是。没有请求链接的注释会得到空数组,而不是错误
1 .. 4096 的 MaxDepth 会在打开任何注释之前引发 EPdfError
var
Chain: TPdfIntegerArray;
Index: Integer;
begin
// 收集注释 5 下方的完整回复串
Chain := Pdf1.GetLinkedAnnotationChain(5, parInReplyTo);
for Index in Chain do
Memo1.Lines.Add(Pdf1.Annotation[Index].ContentsText);
end;