PDFium Component Docs

מתודת CharacterIndexAtPos

Component: TPdfView  ·  Unit: PDFium
מחזיר את אינדקס התו בדף הנוכחי הקרוב ביותר לפיקסל המסך (X, Y), או -1 אם אין תו קרוב מספיק

Syntax

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

Description

Returns the character index in the current page nearest to the screen pixel (X, Y), or -1 if no character is close enough.

Use in OnMouseDown to initiate text selection.

TPdfView maintains the device-to-page transform internally based on Zoom, Rotation, page padding, and scroll offset; these helpers are the safe public interface to that transform.

Remarks

Example

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;

See Also

DeviceToPage, CurrentCharIndex, CharacterCount