PDFium Delphi Component Docs

ReadCurrentPageLinks method

Component: TPdf  ·  Unit: PDFium
Read the current page's link annotations and text web links with one positive cap per kind

Syntax

procedure ReadCurrentPageLinks(MaxLinksPerKind: Integer; out AnnotationLinks: TLinkAnnotations; out TextLinks: TWebLinks; out Limited: Boolean);

MaxLinksPerKindInteger. Maximum number of links returned per kind; must be positive or the call raises EPdfError
AnnotationLinksTLinkAnnotations. Native link annotations of the current page, at most MaxLinksPerKind entries
TextLinksTWebLinks. URLs auto-detected in the page text, at most MaxLinksPerKind entries
LimitedBoolean. True when either kind had more links than the cap allowed

Description

Reads both link kinds of the active page in one call under the render lock: AnnotationLinks enumerates the native link annotations, while TextLinks loads the text page's auto-detected URLs. The cap applies to each kind separately, so a page with many annotations and few URLs returns up to MaxLinksPerKind of each

The cap bounds both native enumeration and Pascal-side materialization: annotation enumeration stops at the limit instead of walking the full list, and a text link count above the cap is truncated before the records are built. Limited is the union of both overflow flags — re-read with a higher cap or page through the unbounded LinkAnnotation property when it is True

Unlike the cached LinkAnnotation and WebLink properties, this method reads fresh arrays on every call and stores no cache; annotation handles inside the records stay valid while the page remains active

PDFium detects text links across the whole page before their count is available, so the text kind pays its full detection pass even when the cap truncates the returned records

Example

var AnnotationLinks: TLinkAnnotations; TextLinks: TWebLinks; Limited: Boolean;
Pdf.ReadCurrentPageLinks(256, AnnotationLinks, TextLinks, Limited);
if Limited then
  FlagPageForManualLinkReview;

See Also

LinkAnnotation, LinkAnnotationCount, LinkAtPoint, WebLink