function GetLinkedAnnotationIndex(AnnotIndex: Integer; Relationship: TPdfAnnotationRelationship): Integer;
| AnnotIndex | Integer. Zero-based index of the annotation on the current page, in the range 0 .. AnnotationCount - 1. An out-of-range index raises an EPdfError. |
| Relationship | TPdfAnnotationRelationship. parPopup follows the /Popup entry (the popup window of a markup annotation); parInReplyTo follows the /IRT entry (the annotation this one replies to). |
| Result | Integer. Page index of the linked annotation in 0 .. AnnotationCount - 1, or -1 when the annotation has no such link. |
Markup annotations can reference other annotations. A text note keeps a popup window in /Popup, and a reply carries the annotation it answers in /IRT. This call resolves one such reference through the native interface (FPDFAnnot_GetLinkedAnnot) and translates the linked annotation handle back into the page annotation index used everywhere else, so the caller can inspect it through Annotation
When the annotation has no entry for the requested relationship, the result is -1. That is the normal case — most annotations carry neither a popup nor a reply reference
To walk an entire reply thread instead of a single hop, use GetLinkedAnnotationChain
AnnotationCount list as AnnotIndex.
var
PopupIndex: Integer;
begin
PopupIndex := Pdf1.GetLinkedAnnotationIndex(3, parPopup);
if PopupIndex >= 0 then
Memo1.Lines.Add(Pdf1.Annotation[PopupIndex].ContentsText);
end;