PDFium Delphi Component Docs

FindFirst 方法

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

語法

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

傳回值

第一個符合項目的以 0 起算字元索引,若找不到文字則為 -1

說明

在目前頁面上起始文字搜尋。使用 FindNext 或 FindPrevious 迭代後續符合項目之前,請先呼叫此方法。每次呼叫 FindFirst 都會重設內部搜尋控制代碼

若要在不迭代的情況下以視覺方式醒目提示所有出現位置,請改用 HighlightSearchText

範例

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;

另請參閱

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