API referencePDF/A & Conformance

pdfApplyAppEvent

Apply an optional-content application-event's visibility

C
BOOL32 __stdcall pdfApplyAppEvent(PPDF IPDF, TOCAppEvent Event, BOOL32 SaveResult);
Delphi
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.

ParameterDescription
IPDFDocument handle.
EventWhich application event to simulate (a bitmask: view/print/export).
SaveResultAccepted; 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)

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

Core

Exported names

pdfApplyAppEvent

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.