PDFium Delphi Component Docs

ReadCurrentPageLinks method

Component: TPdf  ·  Unit: PDFium
Reads 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; it must be positive, otherwise the call raises EPdfError
AnnotationLinksTLinkAnnotations. Native link annotations of the current page, at most MaxLinksPerKind entries
TextLinksTWebLinks. URLs detected automatically in the page text, at most MaxLinksPerKind entries
LimitedBoolean. True when either kind held 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, whilst TextLinks loads the URLs the text page detects automatically. 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 the native enumeration and the Pascal-side materialisation: 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, where it is True

Unlike the cached LinkAnnotation and WebLink properties, this method reads fresh arrays on every call and stores no cache; the annotation handles inside the records stay valid whilst 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 where 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