PDFiumPas 文件

FindFirst 方法

元件: TPdfView  ·  單元: PDFium
開始搜尋指定文字。StartIndex 以 0 為起點,-1 表示從頁面結尾開始。DirectionUp 參數決定本次搜尋方向

Syntax

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

Return Value

第一個符合項目的字元索引,索引從 0 開始;若找不到文字則回傳 -1

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