PDFiumVCL Docs

FindFirst method

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
Component: TPdfView  ·  Unit: PDFium
Start a search of the specified text. StartIndex is 0-based, -1 is for end of the page. DirectionUp parameter determines direction of this search operation.

Syntax

function FindFirst(const Text: WString; Options: TSearchOptions = []; StartIndex: Integer = 0; DirectionUp: Boolean = True): Integer;

TextWString. The text string to search for on the current page.
OptionsTSearchOptions. Set of search flags (e.g. soMatchCase, soMatchWholeWord).
StartIndexInteger. 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.
DirectionUpBoolean. When True (default), searches from StartIndex toward the end of the page. When False, searches backwards.

Return Value

The 0-based character index of the first match, or -1 if the text is not found.

Description

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.

Example

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;

See Also

TPdfView.FindNext, TPdfView.FindPrevious, TPdfView.Find, TPdfView.HighlightSearchText