The PDF optional content model has three main objects:
Optional Content Group (OCG) — The fundamental unit: a named dictionary object with a
/Name string. Each OCG has a state: on or off. Page content is associated with an OCG via
marked content sequences tagged with
/OC operators referencing the OCG. When an OCG is off, its associated content is not rendered.
Optional Content Group Membership Dictionary (OCMD) — A more advanced object that expresses boolean combinations of OCG states: content is visible if (OCG-A is on AND OCG-B is off), for example. OCMDs enable complex conditional visibility logic.
Optional Content Properties Dictionary (/OCProperties) — Stored in the document catalogue, this is the master registry of all OCGs in the document, plus default states and display intent information. It defines which OCGs are in the "Default" intent (normal viewing), "View" intent, and "Print" intent — allowing different layer states for screen viewing vs. printing.
Layer groups and nesting — The
/OCProperties dictionary contains an
/D (default configuration) entry that specifies display order, nesting/grouping of OCGs (for UI presentation in the Layers panel), and initial ON/OFF states. This is purely for UI organisation — the technical visibility mechanism is per-OCG state, not hierarchical.