pdfGetObjectToString
Low-level PDF object-graph introspection/patching: query the
int32_t __stdcall pdfGetMaxObjectNumber(PPDF IPDF);
int32_t __stdcall pdfGetObjectCount(PPDF IPDF);
const char* __stdcall pdfGetObjectToString(PPDF IPDF, int32_t ObjectNumber);
int32_t __stdcall pdfSetObjectFromString(PPDF IPDF, int32_t ObjectNumber, const char* Source);
function pdfGetMaxObjectNumber(const IPDF: PPDF): Integer; stdcall;
function pdfGetObjectCount(const IPDF: PPDF): Integer; stdcall;
function pdfGetObjectToString(const IPDF: PPDF; ObjectNumber: Integer): PAnsiChar; stdcall;
function pdfSetObjectFromString(const IPDF: PPDF; ObjectNumber: Integer; Source: PAnsiChar): Integer; stdcall;
Purpose. Low-level PDF object-graph introspection/patching: query the highest allocated object number, total object count, dump a specific object's serialized PDF syntax as a string, or overwrite one from a caller-supplied string.
Description. All four are real. pdfGetObjectToString serializes whatever the target object currently holds (dict/array/stream header, etc.) into PDF syntax text via GetObjectAsString, returned through a document-owned transient buffer. pdfSetObjectFromString parses Source and replaces the target object's content via SetObjectFromStr — this is a genuinely low-level escape hatch that can corrupt the document's object graph if used carelessly (e.g. writing a dict where a stream was expected, or breaking a cross-reference another object depends on); no structural validation beyond basic parseability is implied here.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
ObjectNumber | Target object's number. |
Source | *(SetObjectFromString only)* New PDF syntax text for the object. |
Return value. pdfGetMaxObjectNumber/pdfGetObjectCount: the respective count; 0 if IPDF invalid. pdfGetObjectToString: pointer to a transient buffer with the object's PDF syntax, or nil if ObjectNumber doesn't resolve. pdfSetObjectFromString: 1 on success; 0 if IPDF/Source invalid.
C# (P/Invoke)
public static extern IntPtr pdfGetObjectToString(IntPtr IPDF, int ObjectNumber);
Getters
pdfGetObjectToString
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.