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 sztring) a kinyert karakterekkel. Üres sztringet ad vissza, ha a StartIndex az oldal szövegének vége után van, vagy ha az oldal nem tartalmaz kinyerhető szövegetText extracts the Unicode text content from the current page as a plain string. It reads from the page's internal text layer — the same layer used by PDF viewers for text selection and search — so the result reflects the logical reading order as determined by PDFium, which may differ from the visual order for complex layouts.
The optional StartIndex and Count parameters allow extracting a substring of the full page text. StartIndex is zero-based; omitting both parameters returns the entire page text. Use CharacterCount to determine the total number of extractable characters on the page before using index-based access.
This method extracts text from a loaded PDF page. It does not interact with text objects added via AddText until the document has been saved and reloaded. To extract text within a specific rectangular region, use TextInRectangle instead.
// Extract all text from the first page
Pdf1.LoadFromFile('C:\Docs\report.pdf');
Pdf1.PageIndex := 0;
ShowMessage(Pdf1.Text);
// Extract characters 10..29 (20 characters)
var S: WString;
begin
S := Pdf1.Text(10, 20);
end;