API referenceCore SDK

pdfCreateOCMD

Create an optional-content membership dictionary — visibility

CategoryOptional content

Purpose — Create an optional-content membership dictionary — visibility driven by a boolean policy over a *set* of OCGs, rather than one OCG alone.

Description — Resolves each handle in OCGs to a live OCG (invalid entries are silently dropped); fails if none resolve. Stores the member set and Visibility policy, and returns a handle in the disjoint OCMD range (1,000,000 + index + 1) usable directly with pdfBeginLayer. Visibility is written to the serialized /OCMD /P entry: ovAllOffAllOff, ovAllOnAllOn, ovAnyOffAnyOff, ovAnyOnAnyOn; ovNotSet omits /P (PDF viewers then default to AnyOn per spec).

Declarations

C
int32_t __stdcall pdfCreateOCMD(PPDF IPDF, TOCVisibility Visibility, uint32_t* OCGs, uint32_t Count);
Delphi
function pdfCreateOCMD(const IPDF: PPDF; Visibility: TOCVisibility; const OCGs: PCardinal; Count: Cardinal): Integer; stdcall; external 'LumasPdf.dll';

TOCVisibility:

Delphi
TOCVisibility = (ovAllOff, ovAllOn, ovAnyOff, ovAnyOn, ovNotSet);

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
VisibilityTOCVisibilityMembership visibility policy — real, reaches the serialized file.
OCGsuint32_t*Array of OCG handles to include.
Countuint32_tNumber of entries in OCGs.

Return value — OCMD handle (>= 1,000,001) on success; 0 if Count is 0, OCGs is NULL, or none of the given handles resolve to a live OCG.

See alsopdfBeginLayer, pdfCreateOCG

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfCreateOCMD(IntPtr IPDF, TOCVisibility Visibility, uint[] OCGs, uint Count);
Area
Core SDK
Category

Object Creation

Exported names

pdfCreateOCMD

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.