What is an OCG?
An OCG (Optional Content Group) , defined in ISO 32000-2:2020, clause 8.11, is a PDF feature that enables selectable layers in interactive PDF viewers.
OCGs let users show or hide specific content, such as text, images, or annotations, within a PDF. Commonly used for technical drawings, multilingual documents, or layered graphics, OCGs improve interactivity and customization in PDF presentations.
How optional content works
An optional content group is a named handle, not a container. Page content is tagged as belonging to a group, and the group is then switched on or off as a whole. This is why a single layer can span several pages and why turning one off can affect artwork, text, and annotations at the same time.
The document stores a configuration that records which groups are visible by default, and viewers show that through a layers panel. Groups can also be controlled automatically instead of manually, for example by zoom level, so that fine detail appears only when a drawing is magnified.
How optional content is used
- Technical and CAD drawings, where dimensions, annotations, and construction lines each occupy their own layer.
- Maps, with separate layers for roads, labels, contours, and boundaries.
- Multilingual documents, with one language per layer over a shared design.
- Print production, where a varnish or die-cut layer must be visible to the operator but not to the reader.
Optional content is what most people mean when they talk about layers in a PDF. Switching a layer off hides it; it does not remove it, and the hidden content is still present in the file.