Class: OCG

PDFNet. OCG


new OCG()

optional-content group

Methods


<static> create(pdfdoc, name)

Constructor
Parameters:
Name Type Description
pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
name string
Returns:
A promise that resolves to an object of type: "PDFNet.OCG"
Type
Promise.<PDFNet.OCG>

<static> createFromObj(ocg_dict)

Parameters:
Name Type Description
ocg_dict PDFNet.Obj
Returns:
A promise that resolves to an object of type: "PDFNet.OCG"
Type
Promise.<PDFNet.OCG>

copy()

Copy Constructor
Returns:
A promise that resolves to an object of type: "PDFNet.OCG"
Type
Promise.<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
Promise.<boolean>

getInitialState(cfg)

Parameters:
Name Type Description
cfg PDFNet.OCGConfig The configuration for which to get the group's initial state. Note: If the configuration has a BaseState of Unchanged, and the OCG is not listed explicitly in its ON list or OFF list, then the initial state is taken from the OCG's current state in the document's default context.
Returns:
A promise that resolves to the initial state (ON or OFF) of the optional-content group (OCG) object in a given configuration.
Type
Promise.<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
Promise.<PDFNet.Obj>

getName()

Returns:
A promise that resolves to the name of this optional-content group (OCG).
Type
Promise.<string>

getSDFObj()

Returns:
A promise that resolves to pointer to the underlying SDF/Cos object.
Type
Promise.<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
Promise.<PDFNet.Obj>

hasUsage()

Returns:
A promise that resolves to true if this group is associated with a Usage dictionary, false otherwise.
Type
Promise.<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
Promise.<boolean>

isValid()

Returns:
A promise that resolves to true if this is a valid (non-null) OCG, false otherwise.
Type
Promise.<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.
Returns:
Type
Promise.<void>

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.
Returns:
Type
Promise.<void>

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).
Returns:
Type
Promise.<void>

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.
Returns:
Type
Promise.<void>

setName(value)

Sets the name of this optional-content group (OCG).
Parameters:
Name Type Description
value string The new name.
Returns:
Type
Promise.<void>