# Class: OCG

## PDFNet. OCG

#### new OCG()

  optional-content group

### Methods

#### <static> create(pdfdoc, name)

  Constructor

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pdfdoc` | PDFNet.PDFDoc |
  `name` | string |

  ##### Returns:

  A promise that resolves to an object of type: "OCG"

  Type
    PDFNet.OCG

#### <static> createFromObj(ocg_dict)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `ocg_dict` | PDFNet.Obj |

  ##### Returns:

  A promise that resolves to an object of type: "OCG"

  Type
    PDFNet.OCG

#### copy()

  Copy Constructor

  ##### Returns:

  A promise that resolves to an object of type: "OCG"

  Type
    PDFNet.OCG

#### getCurrentState(ctx)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `ctx` | PDFNet.OCGContext | The context for which to get the group's state.

  ##### Returns:

  A promise that resolves to true if this OCG object is in the ON state in a given context, false otherwise.

  Type
    boolean

#### getInitialState(cfg)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `cfg` | PDFNet.OCGConfig | The configuration for which to get the group's initial state.

  ##### Returns:

  A promise that resolves to the initial state (ON or OFF) of the optional-content group (OCG) object in a given configuration.

  Type
    boolean

#### getIntent()

  ##### Returns:

  A promise that resolves to oCG intent. An intent is a name object (or an array of name objects) broadly describing the intended use, which can be either "View" or "Design". A group's content is considered to be optional (that is, the group's state is considered in its visibility) if any intent in its list matches an intent of the context. The intent list of the context is usually set from the intent list of the document configuration.

  Type
    PDFNet.Obj

#### getName()

  ##### Returns:

  A promise that resolves to the name of this optional-content group (OCG).

  Type
    string

#### getSDFObj()

  ##### Returns:

  A promise that resolves to pointer to the underlying SDF/Cos object.

  Type
    PDFNet.Obj

#### getUsage(key)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `key` | string | The usage key in the usage dictionary entry. The possible key values are: CreatorInfo, Language, Export, Zoom, Print, View, User, PageElement.

  ##### Returns:

  A promise that resolves to the usage information associated with the given key in the Usage dictionary for the group, or a NULL if the entry is not present. A Usage dictionary entry provides more specific intended usage information than an intent entry.

  Type
    PDFNet.Obj

#### hasUsage()

  ##### Returns:

  A promise that resolves to true if this group is associated with a Usage dictionary, false otherwise.

  Type
    boolean

#### isLocked(cfg)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `cfg` | PDFNet.OCGConfig | The OC configuration.

  ##### Returns:

  A promise that resolves to true if this OCG is locked in a given configuration, false otherwise. The on/off state of a locked OCG cannot be toggled by the user through the user interface.

  Type
    boolean

#### isValid()

  ##### Returns:

  A promise that resolves to true if this is a valid (non-null) OCG, false otherwise.

  Type
    boolean

#### setCurrentState(ctx, state)

  sets the current ON-OFF state of the optional-content group (OCG) object in a given context.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `ctx` | PDFNet.OCGContext | The context for which to set the group's state.
  `state` | boolean | The new state.

#### setInitialState(cfg, state)

  sets the initial state (ON or OFF) of the optional-content group (OCG) object in a given configuration.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `cfg` | PDFNet.OCGConfig | The configuration for which to set the group's initial state.
  `state` | boolean | The new initial state, true if the state is ON, false if it is OFF.

#### setIntent(value)

  Sets the Intent entry in an optional-content group's SDF/Cos dictionary. For more information, see GetIntent().

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | PDFNet.Obj | The new Intent entry value (a name object or an array of name objects).

#### setLocked(cfg, state)

  Sets the locked state of an OCG in a given configuration. The on/off state of a locked OCG cannot be toggled by the user through the user interface.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `cfg` | PDFNet.OCGConfig | IN/OUT The optional-content configuration.
  `state` | boolean | true if the OCG should be locked, false otherwise.

#### setName(value)

  sets the name of this optional-content group (OCG).

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | string | The new name.

#### Search results