API referencePDF/A & Conformance

pdfAddOCGToAppEvent

Subscribe an OCG to one or more application events

C
BOOL32 __stdcall pdfAddOCGToAppEvent(PPDF IPDF, uint32_t Handle, TOCAppEvent Events, TOCGUsageCategory Categories);
Delphi
function pdfAddOCGToAppEvent(const IPDF: PPDF; Handle: Cardinal; Events: TOCAppEvent; Categories: TOCGUsageCategory): LongBool; stdcall;

Purpose. Subscribe an OCG to one or more application events (view/print/export) — the registration step that pdfApplyAppEvent (Form Actions, JavaScript, Application Events, and Layer Object Association) later consults to decide which OCGs' visibility to update when a given event is simulated.

Description. Sets bits in the OCG's FOCGAppEvent bitmask (OR'd with Events) — this is the companion "add" call to the document-level pdfClearOCGAppEvent-style removal function (not itself part of this volume). Categories presumably selects which /Usage sub-dictionary categories (e.g. /View, /Print, /Export) the subscription targets, mirroring the standard PDF optional-content usage-application dictionary structure — this chapter did not trace Categories' exact per-bit effect beyond its being stored alongside Events.

Parameters.

ParameterDescription
IPDFDocument handle.
HandleTarget OCG handle.
EventsBitmask of application events (view/print/export) to subscribe to.
CategoriesWhich /Usage category dictionaries the subscription covers.

Return value. True on success.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
PDF/A & Conformance
Category

Content Creation

Exported names

pdfAddOCGToAppEvent

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.