function FindFirst(const Text: WString; Options: TSearchOptions = []; StartIndex: Integer = 0; DirectionUp: Boolean = True): Integer;
| Text | WString. Geçerli sayfada aranacak Unicode metin dizesi. |
| Options | TSearchOptions. A set of TSearchOption flags that control matching behaviour. Supported flags are soMatchCase (case-sensitive match) and soMatchWholeWord (whole-word match only). Pass [] for a case-insensitive, substring search. |
| StartIndex | Integer. The 0-based character index at which the search begins. Pass -1 sayfadaki son karakterden başlamak için (şu durumda yararlıdır DirectionUp is False). Defaults to 0. |
| DirectionUp | Boolean. Determines the initial search direction. True (default) searches from StartIndex toward the end of the page; False searches toward the beginning. Subsequent calls to FindNext always move forward; FindPrevious always moves backward. |
-1 eşleşme bulunmazsa. Dahili arama tanıtıcısı tutulur, böylece sonraki şu çağrılar FindNext or FindPrevious can continue the search without reinitialisation.FindFirst initiates a full-text search on the currently loaded PDF page. It accepts a Unicode search string together with optional matching flags, a starting character position, and a direction hint. On success it returns the 0-based character index of the first match and stores an internal search handle that is reused by subsequent FindNext and FindPrevious calls. Döndürür: -1 when the text is not found.
The StartIndex parametresi aramayı her zaman sayfanın üstünden başlatmak yerine herhangi bir karakter konumundan başlatmanıza izin verir. Şunu geçin 0 (varsayılan) ile ilk karakterden başlayın ya da şunu geçin -1 son karaktere sabitlemek için — şu ile ters arama yaparken kullanışlıdır DirectionUp = False.
Use the Options parameter to refine matching behaviour. soMatchCase enables a case-sensitive comparison; soMatchWholeWord eşleşmeleri yalnızca tam sözcüklerle sınırlar. Her iki bayrak birleştirilebilir. Boş bir küme geçirmek [] performs a case-insensitive substring search.
Once a match is found, call RectangleCount dönen dizini ve bilinen eşleşme uzunluğunu kullanarak sayfadaki eşleşen metnin sınırlayıcı dikdörtgenlerini alın — bir görüntüleyicide arama sonuçlarını vurgulamak için kullanışlıdır.
var
Idx, MatchLen, R, I: Integer;
Rect: TPdfRectangle;
begin
Pdf1.PageIndex := 0;
MatchLen := Length('invoice');
Idx := Pdf1.FindFirst('invoice', [], 0, True);
while Idx >= 0 do
begin
// Retrieve bounding rectangles for the matched text
R := Pdf1.RectangleCount(Idx, MatchLen);
for I := 0 to R - 1 do
begin
Rect := Pdf1.Rectangle[I];
Memo1.Lines.Add(Format('Match at char %d, rect [%.1f,%.1f,%.1f,%.1f]',
[Idx, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom]));
end;
Idx := Pdf1.FindNext;
end;
end;