function LinkZOrderAtPoint(X, Y: Double): Integer;
| X, Y | Double. Point in PDF page units, with the origin at the bottom-left corner of the page |
| Result | Integer. The z-order of the link covering the point as reported by the native hit-test, or -1 when no link covers it |
Companion of LinkAtPoint: rather than 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
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;