PDFium Delphi Component Docs

GetLinkedAnnotationChain 方法

组件: TPdf  ·  单元: PDFium
反复遍历 /Popup 或 /IRT 关系,返回沿途每个链接注释的页面索引,并带有循环保护

语法

function GetLinkedAnnotationChain(AnnotIndex: Integer; Relationship: TPdfAnnotationRelationship; MaxDepth: Integer = 64): TPdfIntegerArray;

AnnotIndexInteger。当前页面上起始注释的从零开始的索引,范围 0 .. AnnotationCount - 1
RelationshipTPdfAnnotationRelationship。parPopup 跟随 /Popup 条目;parInReplyTo 跟随 /IRT 回复条目
MaxDepthInteger。要跟随的最大链接数量。必须在 1 到 4096 之间,否则会引发 EPdfError。默认值为 64
ResultTPdfIntegerArray。按访问顺序排列的链接注释的页面索引。当起始注释没有此类链接时为空

说明

反复应用 GetLinkedAnnotationIndex:从起始注释开始,沿请求的关系前进到下一个注释,然后从那个注释再次前进,沿途收集每个索引。结果是对话的回复串或弹出式注释链,以简单的页面注释索引数组表示

遍历在三种情况下停止:当前注释没有后续链接、已访问链接数量达到 MaxDepth,或下一个索引会重新访问已经看过的注释(起始索引也算作已看过)。循环保护使该调用在 /IRT 条目成环的畸形文档上仍然安全

起始索引本身从不是结果的一部分 — 只有它指向的注释才是。没有请求链接的注释会得到空数组,而不是错误

备注

示例

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;

参见

GetLinkedAnnotationIndex, Annotation, AnnotationCount