API referenceCore SDK

pdfGetContent

Read/replace the raw content-stream bytes of a page — the

C
int32_t __stdcall pdfGetContent(PPDF IPDF, const char* Buffer);
BOOL32 __stdcall pdfSetContent(PPDF IPDF, const char* Buffer, uint32_t BufSize);
Delphi
function pdfGetContent(const IPDF: PPDF; var Buffer: PAnsiChar): Integer; stdcall;
function pdfSetContent(const IPDF: PPDF; Buffer: PAnsiChar; BufSize: Cardinal): LongBool; stdcall;

Purpose. Read/replace the raw content-stream bytes of a page — the lowest-level content-stream escape hatch in this SDK, alongside pdfGetObjectToString/pdfSetObjectFromString (Document Lifecycle, Locking, and Object Introspection).

Description. **pdfGetContent's Buffer is an output-only var PAnsiChar despite its misleading const char* C declaration — the same output-disguised-as-input pattern already confirmed for pdfGetSeparationInfo (Separation Color Spaces, DeviceN Attributes, OCG UI Tree, and PDF Collections) and pdfGetPtDataArray/Obj (Separation Color Spaces, DeviceN Attributes, OCG UI Tree, and PDF Collections). It reads whichever page is FCurrentPageIdx. pdfSetContent, by contrast, always writes to the document's FPages's last page (FPages.Count - 1) — not necessarily the current page** if pdfEditPage has reopened an earlier one; a real, easy-to-miss asymmetry between the getter (current page) and setter (always-last page).

Parameters.

ParameterDescription
IPDFDocument handle.
Buffer*(Get)* Output only — the current page's raw content bytes. *(Set)* Input — new content bytes, applied to the last page regardless of which page is current.
BufSize*(Set only)* Byte length of Buffer.

Return value. pdfGetContent: byte length of the content (0 if no current page). pdfSetContent: True if Buffer is non-null, BufSize > 0, and at least one page exists.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfGetContent(IntPtr IPDF, ref IntPtr Buffer);
Area
Core SDK
Category

Getters

Exported names

pdfGetContent

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.