API referenceCore SDK

pdfCreateOCLayerConfig

Create a named alternate optional-content configuration (a

CategoryOptional content
Exported namespdfCreateOCLayerConfigA (ANSI only)

Purpose — Create a named alternate optional-content configuration (a saved "view" toggling a set of layers, distinct from the default /D config).

Description — Registers a new entry in /OCProperties/Configs. Intent of 0 defaults to oiView (4); any other value is stored as given. BaseStateOff sets the config's /BaseState (TRUE/OFF: every OCG starts OFF under this config unless explicitly turned on via pdfSetOCGConfigState/pdfAddOCGRadioGroup; FALSE→every OCG starts ON). Returns a 1-based config handle; note this is a config-*handle* (used by pdfSetOCGConfigState/pdfAddOCGRadioGroup), one greater than the config-*index* used by pdfLoadLayerConfig and pdfGetLayerConfig — see those entries for the index-vs-handle distinction.

Declarations

C
int32_t __stdcall pdfCreateOCLayerConfigA(PPDF IPDF, const char* Name, const char* Creator, uint32_t Intent, BOOL32 BaseStateOff);
Delphi
function pdfCreateOCLayerConfigA(const IPDF: PPDF; const Name, Creator: PAnsiChar; Intent: Cardinal; BaseStateOff: LongBool): Integer; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
NamePAnsiCharConfiguration name shown to the user.
CreatorPAnsiChar/Creator metadata string for the configuration.
IntentCardinalTOCGIntent bit value; 0 defaults to oiView (4).
BaseStateOffBOOL32TRUE = every layer starts OFF under this config unless explicitly turned on.

Return value — 1-based config handle (> 0).

See alsopdfLoadLayerConfig, pdfGetLayerConfig

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfCreateOCLayerConfigA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string Name, [MarshalAs(UnmanagedType.LPStr)] string Creator, uint Intent, [MarshalAs(UnmanagedType.Bool)] bool BaseStateOff);
Area
Core SDK
Category

Object Creation

Exported names

pdfCreateOCLayerConfigA

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.