| ImageEn, unit iexUserInteractions |  | 
 
TIEPdfViewer.GetText
 
Declaration
function GetText(CharIndex, CharCount: Integer): string; overload;
function GetText(const R: TRect; ScreenValues: Boolean = True): string; overload;
function GetText(FormatLayout: Boolean = False; ExcludeVertText: Boolean = False): string; overload;
Description
Returns the text at the specified position and length (in characters) or within a specified area (in screen pixels or PDF positions).
The final overload returns all text on the current page. If FormatLayout is true it pads the output with extra lines and spaces to approximate the original layout (you should display with a fixed width font, such as "Courier New"). If ExcludeVertText is true, vertical text - which tends to output as gobbledygook - is removed. Note: ExcludeVertText may remove horizontal text, so it should only be used when needed.
Note:
◼CharIndex is zero-based
◼To convert a screen position to a CharIndex, use 
ScrToCharIndex
◼Result may include a new line character (#$A) so it is best to trim the result
 |   | Demos\PDF\PDFViewer\PdfViewer.dpr | 
s := ImageEnView1.PdfViewer.GetText( Rect( 100, 100, 200, 200 ));
// Show the text word 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 := Trim( ImageEnView1.PdfViewer.GetText( textIndex, textLength ));
end;
// Output all text of page to a memo (unformatted)
Memo1.Text := ImageEnView1.PdfViewer.GetText();
// Output all text of page to a memo (formatted with lines and leading spaces )
Memo1.Font.Name := 'Courier New'; // Fixed width font
Memo1.Text := ImageEnView1.PdfViewer.GetText( True );

// RESULT
{
                         INTERNATIONAL ORGANIZATION FOR STANDARDIZATION
                         TECHNICAL COMMITTEE 42
                         PHOTOGRAPHY
        Address Reply to:
        Secretariat ISO/TC42
        Photographic and Imaging
        Manufacturers Association, Inc.            ISO/TC42N  4378
        550 Mamaroneck Avenue
        Harrison, NY 10528 USA                     1998-11-24
        Phone: +1 914 698 7603                     Our ref: 42(WG18/Item 189.2)
        FAX:  + 1 914 698 7609
        Email: jimpeyton@pima.net
        Email2: jimpeyton@earthlink.net
                                                                               ISO/DIS 12234-2
                                                                                ISO/TC 42/WG 18
                                                                          Secretariat: ANSI (PIMA)
}
// Enable the "Export Text" button if page contains text
btnSaveText.Enabled := Length( ImageEnView1.PdfViewer.GetText( 0, 100 )) > 10;
// 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
◼CharIndexToLine
◼GetWebLinkAt