PDFium Delphi Component Docs

TPdfDocumentSearch class

Unit: PDFium
Streams forward or backward text matches across a document while retaining native handles for one page only

Methods

MethodDescription
CreateInitializes a document-owned search with text, options, starting page, direction, and cancellation token
DestroyCloses retained native search handles and detaches from the owner document
Next(out Match: TPdfDocumentSearchResult): BooleanReturns the next match or False after completion, cancellation, or owner-document closure

Properties

PropertyTypeDescription
CurrentPageIntegerOne-based page currently being searched
DirectionTPdfDocumentSearchDirectionForward or backward page and match traversal
FinishedBooleanWhether no further result can be produced
CancelledBooleanWhether cooperative cancellation ended the search
MatchCountUInt64Number of matches already returned

TPdfDocumentSearchResult

FieldTypeDescription
PageNumberIntegerOne-based page containing the match
StartIndexIntegerZero-based native text-page character index
CountIntegerNumber of native text-page characters in the match
TextWStringUnicode text extracted from the matched range
RectanglesTPdfRectanglesOne or more merged PDF page-space rectangles for highlighting

Lifetime and concurrency

The caller owns the search and must free it. The owner document tracks live searches only so it can close their native handles before the document is unloaded

Calls into the owner document share its PDFium lock. A single search instance must still be advanced and freed from one coordinated caller, and document editing must not overlap an active search

See Also

TPdf.CreateDocumentSearch, TPdf.FindFirst