PDFium Delphi Component Docs

CharacterIndexAtPos 方法

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

語法

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

說明

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

可在 OnMouseDown 中使用,以啟動文字選取

TPdfView 會在內部依據 Zoom、Rotation、頁面留白與捲動偏移維護裝置到頁面的轉換;這些輔助方法是該轉換的安全公開介面

備註

範例

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