API referenceText

psrExtractText

Extract text from an already-parsed context's runs, optionally

CategoryInteractive text extraction
Notehonors 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

C
BOOL32 __stdcall psrExtractText(PPDF IPDF, IPSR Ctx, TTextExtractionFlags Flags, PFltRect Area, const wchar_t* Text, uint32_t* TextLen);
Delphi
function psrExtractText(const IPDF: PPDF; const Ctx: IPSR; Flags: TTextExtractionFlags; Area: PFltRect; var Text: PWideChar; var TextLen: Cardinal): LongBool; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle (only checked incidentally — the real state lives on Ctx).
CtxIPSRA parsed context from psrParsePage.
FlagsTTextExtractionFlagsSort bits are honored — see Description.
AreaPFltRectOptional origin-point filter, same semantics as pdfExtractText's Area.
TextPWideChar*Receives the extracted text.
TextLenCardinal*Receives the character count.

Return valueTRUE if Ctx is valid; FALSE otherwise.

Memory & buffersText points at Ctx's own buffer, valid until the next call using this Ctx.

See alsopdfExtractText

C# (P/Invoke)

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

Misc

Exported names

psrExtractText

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.