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
  // collect the whole reply thread under annotation 5
  Chain := Pdf1.GetLinkedAnnotationChain(5, parInReplyTo);
  for Index in Chain do
    Memo1.Lines.Add(Pdf1.Annotation[Index].ContentsText);
end;

另請參閱

GetLinkedAnnotationIndex, Annotation, AnnotationCount