function FindFirst(const Text: WString; Options: TSearchOptions = []; StartIndex: Integer = 0; DirectionUp: Boolean = True): Integer;
| Text | WString. The text string to search for on the current page. |
| Options | TSearchOptions. Set of search flags (e.g. soMatchCase, soMatchWholeWord). |
| StartIndex | Integer. 0-based character index to begin searching from. Pass 0 to start from the beginning, or -1 to start from the end of the page. |
| DirectionUp | Boolean. When True (default), searches from StartIndex toward the end of the page. When False, searches backwards. |
-1 if the text is not found.Initiates a text search on the current page. Call this method before using FindNext or FindPrevious to iterate through subsequent matches. Each call to FindFirst resets the internal search handle.
To highlight all occurrences visually without iterating, use HighlightSearchText instead.
var Pos: Integer;
begin
Pos := PdfView.FindFirst('invoice', [soMatchCase]);
while Pos >= 0 do
begin
Memo1.Lines.Add('Found at index: ' + IntToStr(Pos));
Pos := PdfView.FindNext;
end;
end;