API referenceCore SDK

pdfSetOCGContUsage

Set the /Usage (application) dictionary fields for a layer —

CategoryOptional content

Purpose — Set the /Usage (application) dictionary fields for a layer — how it should behave under View/Print/Export intents and its /CreatorInfo.

Description — Fields left at -1/empty in Value are not changed (this call only overwrites fields you explicitly set — call pdfInitOCGContUsage first so untouched fields stay -1). UserNameA/UserNameW, when non-empty, are appended to a per-OCG list rather than replacing a single value — repeated calls accumulate multiple /User /Name entries for the same OCG (see pdfGetOCGUsageUserName to enumerate them all; pdfGetOCGContUsage only ever surfaces the first one).

Declarations

C
BOOL32 __stdcall pdfSetOCGContUsage(PPDF IPDF, uint32_t Handle, TPDFOCGContUsage* Value);
Delphi
function pdfSetOCGContUsage(const IPDF: PPDF; Handle: Cardinal; var Value: TPDFOCGContUsage): LongBool; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
HandleCardinalOCG handle.
ValueTPDFOCGContUsage*Fields to apply; -1/empty fields are left unchanged.

Return valueTRUE on success; FALSE if Handle is out of range.

See alsopdfGetOCGContUsage, pdfGetOCGUsageUserName

C# (P/Invoke)

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

Setters

Exported names

pdfSetOCGContUsage

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.