PDFium Delphi Component Docs

LinkAtPoint method

Component: TPdf  ·  Unit: PDFium
Hit-test a page coordinate against the native link annotations of the current page

Syntax

function LinkAtPoint(X, Y: Double): Boolean;

X, YDouble. Point in PDF page units, with the origin at the bottom-left corner of the page
ResultBoolean. True when a link annotation covers that point

Description

Asks PDFium itself whether a link is present, rather than scanning the rectangles of LinkAnnotation. The native test honours the quad points of the annotation, so a link that follows wrapped text is matched on its actual shape rather than on the bounding box that encloses it

It answers presence only. To read the destination or URI, walk LinkAnnotation and LinkAnnotationCount, or use WebLink for URLs auto-detected in page text

Convert a mouse position to page units with DeviceToPage before calling

Example

var PX, PY: Double;
if Pdf.DeviceToPage(X, Y, 0, 0, W, H, ro0, PX, PY) then
  if Pdf.LinkAtPoint(PX, PY) then
    Screen.Cursor := crHandPoint;

See Also

LinkAnnotation, LinkAnnotationCount, WebLink, DeviceToPage