| Category | Interactive text extraction |
|---|---|
| Note | honors sort flags (unlike pdfExtractText) |
Purpose — Extract text from an already-parsed context's runs, optionally filtered by area and sorted.
Description — a real behavioral difference from pdfExtractText. This function does honor Flags' sort bits, per the source comment ("G-25: honour the tef* sort flags (were ignored)") — tefSortTextY/tefSortTextXY sort by descending Y then ascending X (top-to-bottom reading order in PDF's bottom-up space); tefSortTextX alone sorts by ascending X only. This is the opposite of pdfExtractText, whose Flags parameter is completely unused — the two "extract text" APIs in this SDK do not treat Flags consistently.
Declarations
BOOL32 __stdcall psrExtractText(PPDF IPDF, IPSR Ctx, TTextExtractionFlags Flags, PFltRect Area, const wchar_t* Text, uint32_t* TextLen);
function psrExtractText(const IPDF: PPDF; const Ctx: IPSR; Flags: TTextExtractionFlags; Area: PFltRect; var Text: PWideChar; var TextLen: Cardinal): LongBool; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle (only checked incidentally — the real state lives on Ctx). |
Ctx | IPSR | A parsed context from psrParsePage. |
Flags | TTextExtractionFlags | Sort bits are honored — see Description. |
Area | PFltRect | Optional origin-point filter, same semantics as pdfExtractText's Area. |
Text | PWideChar* | Receives the extracted text. |
TextLen | Cardinal* | Receives the character count. |
Return value — TRUE if Ctx is valid; FALSE otherwise.
Memory & buffers — Text points at Ctx's own buffer, valid until the next call using this Ctx.
See also — pdfExtractText
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Misc
psrExtractText
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.