Class: OCGConfig

PDFNet. OCGConfig


new OCGConfig()

The OCGConfig object represents an optional-content (OC) configuration structure (see section 4.10.3 in PDF Reference), used to persist a set of visibility states and other optional-content information in a PDF file A document has a default configuration, saved in the D entry in the 'OCProperties' dictionary (that can be obtained using [PDFDoc].getOCConfig()), and can have a list of other configurations, saved as an array in the 'Configs' entry in the OCProperties dictionary.

Configurations are typically used to initialize the OCG ON-OFF states for an optional-content context (OCGContext). The OCG order in the configuration is the order in which the groups appear in the Layers panel of a PDF viewer. The configuration can also define a set of mutually exclusive OCGs, called a radio button group.

Methods


<static> create(pdfdoc, default_config)

Creates a new optional-content configuration object in the document.
Parameters:
Name Type Description
pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document in which the new OCG::Config will be created.
default_config boolean If true, the configuration will be set as the default OCG configuration (i.e. listed as a D entry under 'OCProperties' dictionary).
Returns:
A promise that resolves to the newly created configuration object.
Type
Promise.<PDFNet.OCGConfig>

<static> createFromObj(dict)

Creates a new optional-content configuration from an existing SDF/Cos object.
Parameters:
Name Type Description
dict PDFNet.Obj SDF object to create optional-content configuration from.
Returns:
A promise that resolves to an object of type: "PDFNet.OCGConfig"
Type
Promise.<PDFNet.OCGConfig>

copy()

Copy Constructor
Returns:
A promise that resolves to an object of type: "PDFNet.OCGConfig"
Type
Promise.<PDFNet.OCGConfig>

getCreator()

Returns:
A promise that resolves to the creator property of an optional-content configuration. The string is used to represent the name of the application or feature that created this configuration.
Type
Promise.<string>

getInitBaseState()

Default Value:
  • ON.
Returns:
A promise that resolves to the base initialization state. This state is used to initialize the states of all the OCGs in a document when this configuration is applied. The value of this entry must be one of the following names:
  • ON: The states of all groups are turned ON.
  • OFF: The states of all groups are turned OFF.
  • Unchanged: The states of all groups are left unchanged.
  • After base initialization, the contents of the ON and OFF arrays are processed, overriding the state of the groups included in the arrays.

    Note: If BaseState is present in the document's default configuration dictionary, its value must be "ON".
    Type
    Promise.<string>

    getInitOffStates()

    Returns:
    A promise that resolves to the "OFF" initialization array from the configuration dictionary or NULL if the array is not present. The returned object is an array of optional content groups whose state should be set to OFF when this configuration is applied. Note: If the BaseState entry is OFF, this entry is redundant.
    Type
    Promise.<PDFNet.Obj>

    getInitOnStates()

    Returns:
    A promise that resolves to the "ON" initialization array from the configuration dictionary or NULL if the array is not present. The returned object is an array of optional content groups whose state should be set to ON when this configuration is applied. Note: If the BaseState entry is ON, this entry is redundant.
    Type
    Promise.<PDFNet.Obj>

    getIntent()

    Returns:
    A promise that resolves to oCG configuration 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. If the configuration has no Intent entry, the default value of "View" is used.
    Type
    Promise.<PDFNet.Obj>

    getLockedOCGs()

    Returns:
    A promise that resolves to the list of locked OCGs or NULL if there are no locked OCGs. The on/off state of a locked OCG cannot be toggled by the user through the user interface.
    Type
    Promise.<PDFNet.Obj>

    getName()

    Returns:
    A promise that resolves to the name of an optional-content configuration (suitable for presentation in a user interface).
    Type
    Promise.<string>

    getOrder()

    Returns:
    A promise that resolves to the Obj array that specifies the order of optional content (OC) groups in this configuration or NULL if the configuration does not contain any OCGs. The order of OCGs in the array is used to represent the order in which the group names are displayed in the Layers panel of a PDF viewer application. For more information, please refer to Section 4.10.3 in the PDF Reference.
    Type
    Promise.<PDFNet.Obj>

    getSDFObj()

    Returns:
    A promise that resolves to pointer to the underlying SDF/Cos object.
    Type
    Promise.<PDFNet.Obj>

    setCreator(value)

    sets the creator property of an optional-content configuration. Stores the specified string as the Creator entry in the configuration's SDF/Cos dictionary.
    Parameters:
    Name Type Description
    value string The new creator string.
    Returns:
    Type
    Promise.<void>

    setInitBaseState( [value])

    sets the base initialization state. For more info, please see GetInitBaseState().
    Parameters:
    Name Type Argument Description
    value string <optional>
    new base state ("ON", "OFF", or "Unchanged").
    Returns:
    Type
    Promise.<void>

    setInitOffStates(value)

    sets the 'OFF' initialization array in the configuration dictionary.
    Parameters:
    Name Type Description
    value PDFNet.Obj the initialization array to be used. Note: For more info, please see SetInitOffStates() and section 4.10.3 in PDF Reference.
    Returns:
    Type
    Promise.<void>

    setInitOnStates(value)

    sets the 'ON' initialization array in the configuration dictionary.
    Parameters:
    Name Type Description
    value PDFNet.Obj the initialization array to be used Note: For more info, please see SetInitOnStates() and section 4.10.3 in PDF Reference.
    Returns:
    Type
    Promise.<void>

    setIntent(value)

    Sets the Intent entry in an optional-content configuration'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).
    Returns:
    Type
    Promise.<void>

    setLockedOCGs(value)

    sets the array of locked OCGs. The on/off state of a locked OCG cannot be toggled by the user through the user interface.
    Parameters:
    Name Type Description
    value PDFNet.Obj An SDF/Cos array of OCG objects to be locked in this configuration, or an empty array if the configuration should not contain locked OCGs. The default is the empty array.
    Returns:
    Type
    Promise.<void>

    setName(value)

    sets the name of an optional-content configuration (suitable for presentation in a user interface). The method stores the specified string as the Name entry in the configuration's SDF/Cos dictionary.
    Parameters:
    Name Type Description
    value string The new name string.
    Returns:
    Type
    Promise.<void>

    setOrder(value)

    Sets the user interface display order of optional-content groups (OCGs) in this configuration. This is the order in which the group names are displayed in the Layers panel of a PDF viewer.
    Parameters:
    Name Type Description
    value PDFNet.Obj The SDF/Cos object containing the OCG order array. For more information, please refer to section 4.10.3 in the PDF Reference.
    Returns:
    Type
    Promise.<void>