pdfSetCatalogInformation
Add or overwrite an arbitrary named entry directly under
int32_t __stdcall pdfSetCatalogInformationA(PPDF IPDF, const char* Key, const char* NewValue);
int32_t __stdcall pdfSetCatalogInformationW(PPDF IPDF, const wchar_t* Key, const wchar_t* NewValue);
function pdfSetCatalogInformationA(const IPDF: PPDF; Key, NewValue: PAnsiChar): Integer; stdcall;
function pdfSetCatalogInformationW(const IPDF: PPDF; Key, NewValue: PWideChar): Integer; stdcall;
Purpose. Add or overwrite an arbitrary named entry directly under the document's /Catalog dictionary, emitted at serialization.
Description. Stores Key/Value into CatalogInfo, a TDictionary<string, WideString> consulted once at serialization: every entry is written into the /Catalog dict except nine reserved structural keys, which are silently skipped (Type, Pages, Root, URI, Names, AcroForm, Outlines, StructTreeRoot, Metadata) — "Reserved structural keys are skipped so they cannot corrupt the catalog" (inline comment). A caller who calls pdfSetCatalogInformation('Outlines', ...) gets Result = 1 (the dictionary write succeeds) but the value never reaches the output PDF — the reserved-key filter applies only at the later serialization step, so success here does not guarantee the entry survives to the document. Verified Unicode round-trip gap: although pdfSetCatalogInformationW accepts a full WideString value and stores it as one, the serialization write narrows it — D.Put(AnsiString(ck), PdfLitStr(RawByteString(AnsiString(CIPair.Value)))) — converting both the key and the value through AnsiString (system codepage) before emitting the PDF literal string. Non-codepage- representable Unicode characters in a W-set value are lost at output.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Key | Catalog dictionary key name — silently dropped at serialization if one of the 9 reserved structural names. |
NewValue | The value, stored as a PDF literal string — narrowed to the system codepage at serialization even when set via W. |
Return value. 1 if Key is non-empty (the dictionary write always succeeds regardless of whether the key is reserved); 0 only if IPDF is invalid or Key is empty.
C# (P/Invoke)
public static extern int pdfSetCatalogInformationW(IntPtr IPDF, IntPtr Key, IntPtr NewValue);
public static extern int pdfSetCatalogInformation(IntPtr IPDF, IntPtr Key, IntPtr NewValue);
public static extern int pdfSetCatalogInformationA(IntPtr IPDF, IntPtr Key, IntPtr NewValue);
Setters
pdfSetCatalogInformationW
pdfSetCatalogInformation
pdfSetCatalogInformationA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.