function Text(StartIndex: Integer = 0; Count: Integer = MaxInt): WString;
| StartIndex | Integer. Zero-based index of the first character to extract. Default is 0 (start of page text) |
| Count | Integer. Maximum number of characters to extract. Default is MaxInt, which extracts all remaining characters from StartIndex to the end of the page |
WString (Unicode string) containing the extracted characters. Returns an empty string if StartIndex is beyond the end of the page text or if the page contains no extractable textText pulls the Unicode text out of the current page as a plain string; it reads the page's internal text layer — the same one viewers rely on for selection and search — so results follow the logical reading order PDFium settles on, which can differ from the visual order on complex layouts
The optional StartIndex and Count parameters extract a substring of the full page text; StartIndex is zero-based, and omitting both returns the whole page. Use CharacterCount to work out how many extractable characters the page holds before resorting to index-based access
Text is read from the loaded PDF page; objects added via AddText only show up here once the document has been saved and reopened. To read text within a particular rectangle, use TextInRectangle instead
// Extract all text from the first page
Pdf1.FileName := 'C:\Docs\report.pdf';
Pdf1.Active := True;
Pdf1.PageNumber := 1;
ShowMessage(Pdf1.Text);
// Extract characters 10..29 (20 characters)
var S: WString;
begin
S := Pdf1.Text(10, 20);
end;