PDFium Delphi Component Docs

LinkAnnotationToAnnotationIndex method

Component: TPdf  ·  Unit: PDFium
Map a link to its annotation index for editing

Syntax

function LinkAnnotationToAnnotationIndex(LinkIndex: Integer): Integer;

LinkIndexInteger. Zero-based index into the active page's link annotation list, as returned by GetLinkAnnotations
ResultInteger. Zero-based annotation index for Annotation and UpdateAnnotation, or -1 when the conversion is unavailable or the link is not in the page's annotation list

Description

PDFium exposes two views of the same link: an FPDF_LINK handle from FPDFLink_Enumerate (used by GetLinkAnnotations) and an FPDF_ANNOTATION handle from FPDFPage_GetAnnot (used by Annotation and UpdateAnnotation). This method bridges them with FPDFLink_GetAnnot and FPDFPage_GetAnnotIndex, so an existing link can be edited with the full annotation API instead of only being read

A typical use is to change the URI or the appearance of a link: resolve the index, read the annotation record, modify LinkUri or the colour and border fields, then pass it to UpdateAnnotation. The page must be active and LinkIndex must be within the current page's link count

FPDFLink_GetAnnot transfers ownership of the annotation handle to the caller, so the handle is closed before the method returns. A -1 result means the DLL lacks one of the required exports, or the link is a web link rather than an annotation in the page's /Annots array

TPdfView provides the same method and forwards it to its TPdf component

See Also

LinkAnnotation, LinkAnnotationCount, LinkAtPoint, AddAnnotationFileAttachment