API referenceText

psrFindText

Find the next occurrence of Text within the parsed context's

CategoryInteractive text search
Notecase-insensitive always (see Remarks)

Purpose — Find the next occurrence of Text within the parsed context's runs, optionally continuing from a previous match.

Description — Searches run-by-run starting at Last's position (or the beginning, if Last=NULL); within each run, matches Text as a substring (whole-run boundaries do not constrain a match — a match spanning the exact run being scanned is found, but matches spanning across two runs are not detected, since each run is searched independently). On a hit, fills SelText with the run index (Line), match position (TextPos), length, and an owned copy of the matched substring (TextOP) — and marks the context's internal selection state (consumed by psrGetSelBBox/psrReplaceSelText).

Declarations

C
BOOL32 __stdcall psrFindText(PPDF IPDF, IPSR Ctx, PFltRect Area, TSearchType SearchType, PTextSelection Last, const wchar_t* Text, uint32_t TextLen, TTextSelection* SelText);
Delphi
function psrFindText(const IPDF: PPDF; const Ctx: IPSR; Area: PFltRect; SearchType: TSearchType; Last: PTextSelection; const Text: PWideChar; TextLen: Cardinal; var SelText: TTextSelection): LongBool; stdcall; external 'LumasPdf.dll';

TTextSelection:

Delphi
TTextSelection = record
  StructSize: Cardinal;
  Line:       Cardinal;    // matched run index into Ctx.Runs
  Matrix:     TCTM;        // identity scale + the run's (X,Y) origin as translation
  Sub1, Sub2: Integer;     // unused by this build
  TextLen:    Integer;
  TextOP:     Pointer;     // engine-owned PWideChar of the matched substring
  TextPos:    Integer;     // zero-based char offset within the run's text
  X, Y:       Single;      // the run's origin
  Next, Prev: PTextSelection;  // unused by this build (always nil)
end;

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
CtxIPSRParsed context.
AreaPFltRectNot consulted by the search loop in this build — searches the whole context regardless (only psrExtractText/psrDeleteText honor an area filter; psrFindText does not).
SearchTypeTSearchTypeBit 0 = whole-word matching. No other bits (including any case-sensitivity bit) have a defined effect — see Remarks.
LastPTextSelectionPrevious match to resume after, or NULL to search from the start.
TextPWideCharSearch term.
TextLenCardinalLength of Text.
SelTextTTextSelection*Receives the match.

Return valueTRUE if a match was found; FALSE otherwise (end of runs reached, Ctx invalid, or Text/TextLen empty).

Remarks — verified: search is always case-insensitive. The case-sensitivity behavior is hardcoded (CaseIns := True unconditionally in the implementation) — there is no SearchType bit that makes this search case-sensitive in the current build, regardless of what the ABI's bit layout might suggest is possible.

See alsopsrGetSelText, psrReplaceSelText

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Text
Category

Misc

Exported names

psrFindText

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.