| ImageEn, unit iexUserInteractions |
|
TIEPdfViewer.ScrToCharIndex
Declaration
function ScrToCharIndex(ScrX, ScrY: Integer; ToleranceX: Double = 0; ToleranceY: Double = 0): Integer;
Description
Return the index of the character at the specified position of the current page (specified in screen values).
ToleranceX/ToleranceY specify how much the search can be expanded (in PDF points) to find a character. Pass MAXWORD,MAXWORD to find the nearest character even if not directly at the position.
Result is a zero-based character index, or -1 if a valid character is not found at the position. If the current page is invalid, Result is 0.
Examples
// Return the position of the character at 100, 100
idx := ImageEnView1.PdfViewer.ScrToCharIndex( 100, 100 );
// Return the position of the nearest character at 100, 100
idx := ImageEnView1.PdfViewer.ScrToCharIndex( 100, 100, MAXWORD, MAXWORD );
// Show the Word under the cursor
procedure TfrmMain.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
charIndex, textIndex, textLength: Integer;
begin
charIndex := ImageEnView1.PdfViewer.ScrToCharIndex( X, Y );
ImageEnView1.PdfViewer.CharIndexToWord( charIndex, textIndex, textLength );
lblWord.Caption := ImageEnView1.PdfViewer.GetText( textIndex, textLength );
end;
See Also
◼GetWebLinkAt
◼CharIndexToWord
◼CharIndexToLine
◼PageToScr