API referenceGraphics

pdfSetOCGState

Set an OCG's default visibility in the document's base

C
BOOL32 __stdcall pdfSetOCGState(PPDF IPDF, uint32_t Handle, BOOL32 Visible, BOOL32 SaveState);
Delphi
function pdfSetOCGState(const IPDF: PPDF; Handle: Cardinal; Visible, SaveState: LongBool): LongBool; stdcall;

Purpose. Set an OCG's default visibility in the document's base (default) configuration.

Description. Requires Handle to resolve to an existing OCG (1-based, bounds-checked); on success, sets FOCGVisible[Handle-1] := Visible. The SaveState parameter is accepted by the ABI but never read by the implementation — it is silently dropped, same pattern as pdfCreateSetOCGStateAction's PreserveRB. Its name implies an option to push the previous visibility onto some kind of undo/restore stack before overwriting it, but no such stack exists anywhere in the codebase; the call always performs a plain, non-reversible overwrite regardless of SaveState's value.

Parameters.

ParameterDescription
IPDFDocument handle.
HandleHandle of an existing OCG (1-based).
VisibleNew default-configuration visibility.
SaveStateAccepted but silently dropped — no prior-state save/restore mechanism exists regardless of value.

Return value. True if Handle resolved to an existing OCG; False otherwise.

See also. pdfSetOCGConfigState (the per-alternate-configuration sibling), pdfCreateSetOCGStateAction.

C# (P/Invoke)

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

Setters

Exported names

pdfSetOCGState

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.