# OptionalContentConfig Class

> A structure used to store data related to layers in a PDF.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.4.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentConfig
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class OptionalContentConfig
```

**Namespace:** `datalogics_interface`

## Description

A structure used to store data related to layers in a PDF.

The Optional Content Configuration Structure is used to maintain a set of visibility states and other optional values related to layers, or Optional Content Groups, within a PDF file.

These configuration values are stored for future use.

The default configuration for a PDF document is stored in the D entry in the Optional Content Properties dictionary.

An Optional Content Group, or layer, is a set of graphic images that can be made visible or invisible within a PDF file, and the Optional Content Configuration Structure is typically used to set the initial value for these images-On or Off, visible or invisible.

**Uses types:** [`OptionalContentBaseState`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptionalContentBaseState.md), [`OptionalContentGroup`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentGroup.md), [`OptionalContentOrderArray`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentOrderArray.md), [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md)

## Constructors

### OptionalContentConfig

```cpp
datalogics_interface::OptionalContentConfig::OptionalContentConfig()
```

*constructor*

Create an OCConfig from an internal source

Internal only.

### OptionalContentConfig

```cpp
datalogics_interface::OptionalContentConfig::OptionalContentConfig(const Document &doc)
```

*constructor*

**Parameters**

- `doc` ([`const Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): the Document the OCConfig is in

Create an OCConfig from an internal source

Internal only.

### OptionalContentConfig

```cpp
datalogics_interface::OptionalContentConfig::OptionalContentConfig(OptionalContentConfig &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`OptionalContentConfig &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentConfig.md))

### ~OptionalContentConfig

```cpp
datalogics_interface::OptionalContentConfig::~OptionalContentConfig()
```

*destructor*

## Methods

### get_base_state

```cpp
OptionalContentBaseState datalogics_interface::OptionalContentConfig::get_base_state() const
```

**Returns:** [`OptionalContentBaseState`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptionalContentBaseState.md)

The base state that will be applied to OptionalContentGroups.

Get the base state for this OptionalContentConfig. When this config is applied to an OptionalContentContext, all OptionalContentGroups will be set to according to this base state:

If BaseState is set to BaseStateOff, when this OptionalContentConfig is applied to an OptionalContentContext: All OptionalContentGroups in the document are set to OFF, and Any OptionalContentGroups in this OptionalContentConfig's ON array are then set to on. If BaseState is set to BaseStateOn, when this OptionalContentConfig is applied to an OptionalContentContext: All OptionalContentGroups in the document are set to ON, and Any OptionalContentGroups in this OptionalContentConfig's OFF array are then set to off. If BaseState is set to BaseStateUnchanged, when this OptionalContentConfig is applied to an OptionalContentContext: Any OptionalContentGroups in this OptionalContentConfig's ON array are set to on Any OptionalContentGroups in this OptionalContentConfig's OFF array are set to off Any OptionalContentGroups in neither the ON or OFF array are unaffected

### get_intent

```cpp
std::vector< std::string > datalogics_interface::OptionalContentConfig::get_intent() const
```

**Returns:** `std::vector< std::string >`

An array containing intent strings.

Gets the intent list for an OptionalContentConfig. An intent is a string value broadly describing the intended use, either View or Design.

A config's intent is used to set the intent of an OptionalContentContext when this config is applied to the context.

### get_name

```cpp
std::string datalogics_interface::OptionalContentConfig::get_name() const
```

**Returns:** `std::string`

The name of this OptionalContentConfig. Use null to remove the name.

Get the name of the OptionalContentConfig

### get_off_array

```cpp
std::vector< OptionalContentGroup > datalogics_interface::OptionalContentConfig::get_off_array() const
```

**Returns:** [`std::vector< OptionalContentGroup >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentGroup.md)

A list of all OptionalContentGroups in the OFF array

Get the list of OptionalContentGroups in the OFF array.

When this config is applied to an OptionalContentContext, the OptionalContentGroups in this array will be set to OFF.

This list is ignored if the BaseState is BaseStateOff; please see the description of the BaseState property for details.

Note that an OptionalContentGroup should not be in both the ON array and the OFF array.

### get_on_array

```cpp
std::vector< OptionalContentGroup > datalogics_interface::OptionalContentConfig::get_on_array() const
```

**Returns:** [`std::vector< OptionalContentGroup >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentGroup.md)

A list of all OptionalContentGroups in the ON array

Get the list of OptionalContentGroups in the ON array.

When this config is applied to an OptionalContentContext, the OptionalContentGroups in this array will be set to ON.

This list is ignored if the BaseState is BaseStateOn; please see the description of the BaseState property for details.

Note that an OptionalContentGroup should not be in both the ON array and the OFF array.

### get_order

```cpp
std::unique_ptr< OptionalContentOrderArray > datalogics_interface::OptionalContentConfig::get_order() const
```

**Returns:** [`std::unique_ptr< OptionalContentOrderArray >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentOrderArray.md)

The OptionalContentOrderArray for optional content in this optional content config.

Gets the order list for the optional content in this optional content config.

Note that you can set the Title property on this order list, just as on any other OptionalContentOrderArray, and it will save as a legal PDF. However, the Title property on the top level order array simply appears as an extraneous text label in a PDF Viewer Layers panel, so its use at this level is typically not required.

### get_pdf_dict

```cpp
PDFDict datalogics_interface::OptionalContentConfig::get_pdf_dict() const
```

**Returns:** [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md)

The underlying PDF dictionary for this OptionalContentConfig.

Retrieve the PDFObject representation of this object.

### operator=

```cpp
OptionalContentConfig & datalogics_interface::OptionalContentConfig::operator=(OptionalContentConfig &&) noexcept
```

**Parameters**

- (unnamed) ([`OptionalContentConfig &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentConfig.md))

**Returns:** [`OptionalContentConfig &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentConfig.md)

### set_base_state

```cpp
void datalogics_interface::OptionalContentConfig::set_base_state(OptionalContentBaseState base_state)
```

**Parameters**

- `base_state` ([`OptionalContentBaseState`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptionalContentBaseState.md)): The base state that will be applied to OptionalContentGroups.

**Returns:** `void`

Set the base state for this OptionalContentConfig. When this config is applied to an OptionalContentContext, all OptionalContentGroups will be set to according to this base state:

If BaseState is set to BaseStateOff, when this OptionalContentConfig is applied to an OptionalContentContext: All OptionalContentGroups in the document are set to OFF, and Any OptionalContentGroups in this OptionalContentConfig's ON array are then set to on. If BaseState is set to BaseStateOn, when this OptionalContentConfig is applied to an OptionalContentContext: All OptionalContentGroups in the document are set to ON, and Any OptionalContentGroups in this OptionalContentConfig's OFF array are then set to off. If BaseState is set to BaseStateUnchanged, when this OptionalContentConfig is applied to an OptionalContentContext: Any OptionalContentGroups in this OptionalContentConfig's ON array are set to on Any OptionalContentGroups in this OptionalContentConfig's OFF array are set to off Any OptionalContentGroups in neither the ON or OFF array are unaffected

### set_intent

```cpp
void datalogics_interface::OptionalContentConfig::set_intent(const std::vector< std::string > &intents)
```

**Parameters**

- `intents` (`const std::vector< std::string > &`): An array of intent strings to assign to this config.

**Returns:** `void`

Sets the intent list for an OptionalContentConfig. An intent is a string value broadly describing the intended use, either View or Design.

A config's intent is used to set the intent of an OptionalContentContext when this config is applied to the context.

### set_name

```cpp
void datalogics_interface::OptionalContentConfig::set_name(const std::string &name)
```

**Parameters**

- `name` (`const std::string &`): The name of this OptionalContentConfig. Use null to remove the name.

**Returns:** `void`

Set the name of the optional content group

### set_off_array

```cpp
void datalogics_interface::OptionalContentConfig::set_off_array(std::vector< OptionalContentGroup > ocgs)
```

**Parameters**

- `ocgs` ([`std::vector< OptionalContentGroup >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentGroup.md)): A list of all OptionalContentGroups to be placed in the OFF array

**Returns:** `void`

Set the list of OptionalContentGroups in the OFF array.

When this config is applied to an OptionalContentContext, the OptionalContentGroups in this array will be set to OFF.

This list is ignored if the BaseState is BaseStateOff; please see the description of the BaseState property for details.

Note that an OptionalContentGroup should not be in both the ON array and the OFF array.

### set_on_array

```cpp
void datalogics_interface::OptionalContentConfig::set_on_array(std::vector< OptionalContentGroup > ocgs)
```

**Parameters**

- `ocgs` ([`std::vector< OptionalContentGroup >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentGroup.md)): A list of all OptionalContentGroups to be placed in the ON array

**Returns:** `void`

Set the list of OptionalContentGroups in the ON array.

When this config is applied to an OptionalContentContext, the OptionalContentGroups in this array will be set to ON.

This list is ignored if the BaseState is BaseStateOn; please see the description of the BaseState property for details.

Note that an OptionalContentGroup should not be in both the ON array and the OFF array.
