PDFiumPas 文件

CharacterIndexAtPos 方法

此 API 條目保留識別符號、簽名、程式碼塊和 PDF 術語的原始形式。
元件: TPdfView  ·  單元: PDFium
回傳目前頁面中最接近螢幕像素 (X, Y) 的字元索引;若附近沒有足夠接近的字元則回傳 -1

語法

function CharacterIndexAtPos(X, Y: Integer; ToleranceX, ToleranceY: Double): Integer;

說明

回傳目前頁面中最接近螢幕像素 (X, Y) 的字元索引;若附近沒有足夠接近的字元則回傳 -1

Use in OnMouseDown to initiate text selection.

TPdfView 會根據 Zoom、Rotation、頁面內距與捲動位移在內部維護 device-to-page 轉換;這些輔助函式就是該轉換安全的公開介面

備註

範例

procedure TForm1.PdfView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  PageX, PageY: Double;
begin
  if PdfView1.CharacterIndexAtPos(X, Y, PageX, PageY) then
    Caption := Format('pt = (%.2f, %.2f)', [PageX, PageY]);
end;

另請參閱

DeviceToPage, CurrentCharIndex, CharacterCount