pdfParseContent
Replay the current page's content stream through a table of
| Exported names | pdfParseContent |
|---|---|
| Calling convention | stdcall |
| Thread safety | One PPDF/handle per thread; see V18 §Threading |
| Introduced | LumasPDF 1.0 |
Purpose — Replay the current page's content stream through a table of caller-supplied callback functions, one call per operator.
Description — Parses the active page (when the document holds no authored page — an import-only document — page 1 of the import source is parsed instead, with its content streams decoded first, the same fallback pdfExtractText uses) and dispatches every content operator to the matching callback in Stack: path construction (MoveTo, LineTo, the three BezierTo forms, Rectangle, ClosePath, ClipPath), graphics state (SaveGraphicState/RestoreGraphicState — the full state including the text-state parameters, per ISO 32000 — MulMatrix, SetLineWidth and the other state setters), font selection (SetFont, delivered with the resolved font's name, style, size and embedding state) and text showing.
Text arrives through ShowTextArrayW/ShowTextArrayA as per-record arrays: the W form carries text decoded to Unicode (imported fonts are decoded through their own /ToUnicode maps, two-byte encodings included) together with per-record kerning and advance widths in text space; the text matrix advances record by record. Coordinates handed to the path callbacks are already multiplied through the current transformation matrix. Do operators recurse into the page's Form XObjects (depth-limited to guard against cyclic form references).
Only callbacks the caller assigned are invoked — unused slots may be NULL; every non-NULL slot is validated as a readable pointer before parsing begins.
Declarations
BOOL32 __stdcall pdfParseContent(PPDF IPDF, void* Data, TPDFParseInterface* Stack, int32_t Flags);
function pdfParseContent(const IPDF: PPDF; const Data: Pointer; var Stack: TPDFParseInterface; Flags: Integer): LongBool; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | In/Out | Description |
|---|---|---|---|
IPDF | PPDF | in | Instance handle with an open or imported document. |
Data | Pointer | in | Caller context, passed unchanged as the first argument of every callback. |
Stack | TPDFParseInterface | in | The callback table (41 slots); assign the callbacks you need and zero the rest. |
Flags | Integer | in | Compatibility parameter — accepted but unused. |
Return value — TRUE once the page has been replayed; FALSE when the instance handle is invalid, a non-NULL callback slot is not a readable pointer, or the page's content cannot be read.
Remarks — For finding, replacing or deleting content rather than observing it, the psr* content-parser surface (psrParsePage) offers an editable object model of the same content; pdfParseContent is the streaming, callback-driven view.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfParseContent
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.