API reference › PDF/A & Conformance
pdfApplyAppEvent
Apply an optional-content application-event's visibility
BOOL32 __stdcall pdfApplyAppEvent(PPDF IPDF, TOCAppEvent Event, BOOL32 SaveResult);
function pdfApplyAppEvent(const IPDF: PPDF; Event: TOCAppEvent; SaveResult: LongBool): LongBool; stdcall;
Purpose. Apply an optional-content application-event's visibility rule (View/Print/Export, per each OCG's /Usage dictionary, registered earlier via pdfAddOCGToAppEvent, Optional Content (OCG) Layers) — i.e. simulate "the document was opened for viewing/printing/exporting" and update every subscribed OCG's actual visibility accordingly.
Description. Genuinely real: for every OCG whose registered app-event bitmask (FOCGAppEvent) includes Event, resolves the appropriate per-event usage state (FOCGUseView/UsePrint/UseExport, checked in View → Print → Export priority order via bitmask checks) and sets FOCGVisible accordingly (1 = show, 0 = hide, anything else leaves the current visibility unchanged). SaveResult is accepted by the ABI but this chapter did not find it consulted — there is no separate "preview vs. commit" state distinction in the implementation; the visibility change is applied immediately and directly regardless of this parameter's value.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Event | Which application event to simulate (a bitmask: view/print/export). |
SaveResult | Accepted; not observed to be consulted — the effect is always immediate. |
Return value. True if at least one OCG was subscribed to Event and had its visibility updated; False if none were.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfApplyAppEvent
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.