# OptionalContentConfig

## Content

# Type Alias: OptionalContentConfig

```ts
type OptionalContentConfig = object;
```

Represents an Optional Content Configuration (OCConfig) in a PDF document.
This configuration defines the visibility and behavior of Optional Content Groups (OCGs).

Based on ISO 32000-2, an Optional Content Configuration manages:
- The default state of OCGs.
- The visibility order of layers.
- Application-specific metadata.

## Properties

### creator

```ts
creator: null | string;
```

The name of the application or process that created this configuration.
Can be `null` if unspecified.

***

### name

```ts
name: null | string;
```

A user-friendly name for this configuration.
Can be `null` if unnamed.

***

### viewScale

```ts
viewScale: number;
```

Defines the scaling factor applied when viewing optional content.
This is used to determine the effective visibility of OCGs based on zoom levels.

## Methods

### getGroup()

```ts
getGroup(id): OptionalContentGroup;
```

Retrieves an Optional Content Group (OCG) by its unique identifier.

#### Parameters

##### id

`string`

The ID of the content group.

#### Returns

[`OptionalContentGroup`](OptionalContentGroup)

The corresponding `OptionalContentGroup`, or throws an error if not found.

***

### getGroups()

```ts
getGroups(): object;
```

Retrieves all Optional Content Groups (OCGs) defined in the document.

#### Returns

`object`

An object where the keys are group IDs and the values are `OptionalContentGroup` instances.

***

### getOrder()

```ts
getOrder(): (
  | string
  | {
  name: string | null;
  order: string[];
})[];
```

Retrieves the order in which Optional Content Groups should be displayed in the layers panel.

This can be:
- An array of string IDs representing a simple ordered list of groups.
- An array of objects containing a `name` and an `order`, where `order` is a list of grouped layers.

#### Returns

(
  \| `string`
  \| \{
  `name`: `string` \| `null`;
  `order`: `string`[];
\})[]

The configured display order of the groups.

***

### isVisible()

```ts
isVisible(groupOrId): boolean;
```

Checks whether an Optional Content Group (OCG) is currently visible.

#### Parameters

##### groupOrId

The group instance or its ID.

`string` | [`OptionalContentGroup`](OptionalContentGroup)

#### Returns

`boolean`

`true` if the group is visible, otherwise `false`.

***

### setVisibility()

```ts
setVisibility(id, visible): void;
```

Sets the visibility state of an Optional Content Group (OCG).

#### Parameters

##### id

`string`

The ID of the content group.

##### visible

`boolean`

`true` to make the group visible, `false` to hide it.

#### Returns

`void`
