ImageEn, unit iexUserInteractions |
|
TIEPdfViewer.CharIndexToLine
Declaration
procedure CharIndexToLine(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 entire line.
If the method fails, OutLength will return 0.
Note:
◼CharIndex is zero-based
◼To convert CharIndex/Length to a screen position, use
GetTextRects◼To convert a screen position to a CharIndex, use
ScrToCharIndex// Show the text 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.CharIndexToLine( charIndex, textIndex, textLength );
lblLine.Caption := ImageEnView1.PdfViewer.GetText( textIndex, textLength );
end;
// Output each line of text
var
idx, outIndex, outLength: Integer;
s: String;
begin
Memo1.Clear;
idx := 0;
while idx < MAXINT do // Infinite loop
begin
ImageEnView1.PdfViewer.CharIndexToLine( idx, outIndex, outLength );
if outLength = 0 then
BREAK;
s := ImageEnView1.PdfViewer.GetText( outIndex, outLength );
memo1.Lines.Add( Trim( s ));
idx := outIndex + outLength + 1;
end;
end;
See Also
◼CharIndexToWord◼SelectLine