| Category | Interactive text search |
|---|---|
| Note | case-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
BOOL32 __stdcall psrFindText(PPDF IPDF, IPSR Ctx, PFltRect Area, TSearchType SearchType, PTextSelection Last, const wchar_t* Text, uint32_t TextLen, TTextSelection* SelText);
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:
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
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Ctx | IPSR | Parsed context. |
Area | PFltRect | Not consulted by the search loop in this build — searches the whole context regardless (only psrExtractText/psrDeleteText honor an area filter; psrFindText does not). |
SearchType | TSearchType | Bit 0 = whole-word matching. No other bits (including any case-sensitivity bit) have a defined effect — see Remarks. |
Last | PTextSelection | Previous match to resume after, or NULL to search from the start. |
Text | PWideChar | Search term. |
TextLen | Cardinal | Length of Text. |
SelText | TTextSelection* | Receives the match. |
Return value — TRUE 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 also — psrGetSelText, psrReplaceSelText
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Misc
psrFindText
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.