PDFium Delphi Component Docs

LinkAtPoint メソッド

コンポーネント: TPdf  ·  ユニット: PDFium
ページ座標を現在のページのネイティブリンク注釈に対してヒットテストします

構文

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.

説明

LinkAnnotation の矩形を走査するのではなく、PDFium 自身にリンクの有無を問い合わせます。ネイティブテストは注釈の四辺形点を尊重するため、折り返しテキストに従うリンクは、それを囲む境界ボックスではなく実際の形状で一致します

答えは存在のみです。宛先や URI を読むには LinkAnnotationLinkAnnotationCount を走査するか、ページテキスト内で自動検出された URL には WebLink を使用します

呼び出す前に、マウス位置を DeviceToPage でページ単位に変換します

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;

関連項目

LinkAnnotation, LinkAnnotationCount, WebLink, DeviceToPage