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