ImageEn, unit iexUserInteractions

TIEPdfViewerInteraction.ScrToCharIndex

TIEPdfViewerInteraction.ScrToCharIndex


Declaration

function ScrToCharIndex(ScrX, ScrY: Integer; ToleranceX: Double = 0; ToleranceY: Double = 0): Integer;


Description

Return any the index of the character at specified position of the 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 charater is not found at the position.


Examples

// Return the position of the character at 100, 100
idx := ImageEnView1.PdfViewer.GetCharIndexAt( 100, 100 );

// Return the position of the nearest character at 100, 100
idx := ImageEnView1.PdfViewer.GetCharIndexAt( 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