API referenceCore SDK

pdfSetMetadata

Get/set raw XMP metadata bytes.

C
BOOL32 __stdcall pdfGetMetadata(PPDF IPDF, TMetadataObj ObjType, int32_t Handle, uint8_t* Buffer, uint32_t* BufSize);
BOOL32 __stdcall pdfSetMetadata(PPDF IPDF, TMetadataObj ObjType, int32_t Handle, void* Buffer, uint32_t BufSize);
Delphi
function pdfGetMetadata(const IPDF: PPDF; ObjType: TMetadataObj; Handle: Integer; Buffer: PByte; var BufSize: Cardinal): LongBool; stdcall;
function pdfSetMetadata(const IPDF: PPDF; ObjType: TMetadataObj; Handle: Integer; Buffer: Pointer; BufSize: Cardinal): LongBool; stdcall;

Purpose. Get/set raw XMP metadata bytes.

Description. Verified: ObjType and Handle are accepted by both functions but never consulted — per an explicit source comment on pdfSetMetadata, "document-level XMP (ObjType/Handle ignored)." Despite the ABI shape implying per-object metadata (e.g. attaching distinct XMP to a specific image or page object, selected by ObjType/Handle), both functions always operate on the single document-level /Metadata stream regardless of what ObjType/Handle specify.

Parameters.

ParameterDescription
IPDFDocument handle.
ObjType, HandleAccepted but silently ignored — always targets document-level metadata.
Buffer, BufSizeThe XMP bytes (get: output; set: input).

Return value. pdfGetMetadata: True if document metadata exists and was copied out. pdfSetMetadata: True if IPDF is valid.

C# (P/Invoke)

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

Setters

Exported names

pdfSetMetadata

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.