[]
        
(Showing Draft Content)

OptionalContentConfig

Type Alias: OptionalContentConfig

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.

Type declaration

creator

creator: null | string

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

getGroup()

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

Parameters

id

string

The ID of the content group.

Returns

OptionalContentGroup

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

getGroups()

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()

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()

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

Parameters

groupOrId

The group instance or its ID.

string | OptionalContentGroup

Returns

boolean

true if the group is visible, otherwise false.

name

name: null | string

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

setVisibility()

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

viewScale

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.