class HexaPDF::Type::OptionalContentConfiguration


Represents an optional content configuration dictionary.

This dictionary is used for the /D and /Configs entries in the optional content properties dictionary. It configures the states of the OCGs as well as defines how those states may be changed by a PDF processor.

See: PDF2.0 s8.11.4.3

Field Definitions

NameType/Allowed ValuesRequiredDefault Value
One of: :ON, :OFF, :Unchanged
ONHexaPDF::PDFArray or Arrayfalsenil
OFFHexaPDF::PDFArray or Arrayfalsenil
IntentSymbol or HexaPDF::PDFArray or Arrayfalse:View
ASHexaPDF::PDFArray or Arrayfalsenil
OrderHexaPDF::PDFArray or Arrayfalsenil
One of: :AllPages, :VisiblePages
RBGroupsHexaPDF::PDFArray or Arrayfalsenil
LockedHexaPDF::PDFArray or Arrayfalse[]

Public Instance Methods

add_ocg_to_ui(ocg, path: nil)

Makes the given optional content group visible in an interactive PDF processor’s user interface.

The OCG is always added to the end of the specified path or, if path is not specified, the top level.

The optional argument path specifies the strings or OCGs under which the given OCG should hierarchically be nested. A string is used as a non-selectable label, an OCG reflects an actual nesting of the involved OCGs.


configuration.add_ocg_to_ui(ocg)                   # Add the OCG as top-level item
configuration.add_ocg_to_ui(ocg, path: 'Debug')    # Add the OCG under the label 'Debug'
# Add the OCG under the label 'Page1' which is under the label 'Debug'
configuration.add_ocg_to_ui(ocg, path: ['Debug', 'Page1'])
configuration.add_ocg_to_ui(ocg, path: other_ocg)  # Add the OCG under the other OCG

Returns true if the given optional content group is on.

ocg_state(ocg) → state
ocg_state(ocg, state) → state

Returns the state (:on, :off or nil) of the optional content group if the state argument is not given. Otherwise sets the state of the OCG to the given state value (:on/:ON or :off/:OFF).

The value nil is only returned if the state is not defined by the configuration dictionary (which may only be the case if the configuration dictionary is not the default configuration dictionary).