PDFium Delphi Component Docs

LinkZOrderAtPoint method

Component: TPdf  ·  Unit: PDFium
Hit-tests a page-space coordinate against the native link annotations and returns the z-order of the link covering that point

Syntax

function LinkZOrderAtPoint(X, Y: Double): Integer;

X, YDouble. Point in PDF page units, with the origin at the bottom-left corner of the page.
ResultInteger. The z-order of the link covering the point as reported by the native hit-test, or -1 when no link covers it.

Description

Companion of LinkAtPoint: instead of a plain yes/no answer, the native hit-test (FPDFLink_GetLinkZOrderAtPoint) returns the z-order of the link found at the coordinate. When several links overlap, the z-order identifies which one the viewer should act on at that position

The test runs inside PDFium, so it honours the actual quad-point geometry of link annotations rather than the bounding boxes exposed by LinkAnnotation — a link that follows wrapped text is matched on its real shape

A result of -1 means the point sits on no link. The call requires the current page to be active. Convert a mouse position to page units with DeviceToPage first

Remarks

Example

var PX, PY: Double;
begin
  if Pdf1.DeviceToPage(MouseX, MouseY, 0, 0, W, H, ro0, PX, PY) then
  begin
    Memo1.Lines.Add('Link z-order: ' + IntToStr(Pdf1.LinkZOrderAtPoint(PX, PY)));
    // -1 means the point is not covered by any link
  end;
end;

See Also

LinkAtPoint, LinkAnnotation, LinkAnnotationCount, FormFieldZOrderAtPoint, DeviceToPage