API reference › PDF/A & Conformance
pdfAddOCGToAppEvent
Subscribe an OCG to one or more application events
BOOL32 __stdcall pdfAddOCGToAppEvent(PPDF IPDF, uint32_t Handle, TOCAppEvent Events, TOCGUsageCategory Categories);
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.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Handle | Target OCG handle. |
Events | Bitmask of application events (view/print/export) to subscribe to. |
Categories | Which /Usage category dictionaries the subscription covers. |
Return value. True on success.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Content Creation
pdfAddOCGToAppEvent
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.