ImageEn, unit iexUserInteractions

TIEPdfViewerInteraction.CharIndexToWord

TIEPdfViewerInteraction.CharIndexToWord


Declaration

procedure CharIndexToWord(const CharIndex: Integer; out OutIndex: Integer; out OutLength: Integer);


Description

Converts the index of a character in the current page to the start and end character for the word (that contains the character).
If the method fails, Length will return 0.

Notes:
- CharIndex is zero-based
- To convert CharIndex/Length to a screen position, use GetTextRects
- To convert a screen position to a CharIndex, use ScrToCharIndex


Example

// 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

- CharIndexToLine
- SelectWord