new OCMD()
The OCMD object represents an Optional Content Membership Dictionary (OCMD)
that allows the visibility of optional content to depend on the states in a
set of optional-content groups (OCG::Group). The object directly corresponds
to the OCMD dictionary (Section 4.10.1 'Optional Content Groups' in PDF
Reference).
An OCMD collects a set of OCGs. It sets a visibility policy, so that content in the member groups is visible only when all groups are ON or OFF, or when any of the groups is ON or OFF. This makes it possible to set up complex dependencies among groups. For example, an object can be visible only if some other conditions are met (such as if another layer is visible).
Members
-
<static> VisibilityPolicyType
-
Type:
- number
Properties:
Name Type Description e_AllOn
number e_AnyOn
number e_AnyOff
number e_AllOff
number
Methods
-
<static> create(pdfdoc, ocgs, vis_policy)
-
Creates a new optional-content membership dictionary (OCMD) object in the given document for the given groups and visibility policy.
Parameters:
Name Type Description pdfdoc
PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document in which the new OCMD will be created. ocgs
PDFNet.Obj An array of optional-content groups (OCGs) to be members of the dictionary. vis_policy
number PDFNet.OCMD.VisibilityPolicyType = { e_AllOn : 0 e_AnyOn : 1 e_AnyOff : 2 e_AllOff : 3 }
The visibility policy that determines the visibility of content with respect to the ON-OFF state of OCGs listed in the dictionary.Returns:
A promise that resolves to the newly created OCG::OCMD object.- Type
- Promise.<PDFNet.OCMD>
-
<static> createFromObj(ocmd_dict)
-
Creates a new optional-content group membership dictionary (OCMD) object from an existing SDF/Cos object.
Parameters:
Name Type Description ocmd_dict
PDFNet.Obj Returns:
A promise that resolves to an object of type: "PDFNet.OCMD"- Type
- Promise.<PDFNet.OCMD>
-
copy()
-
Copy Constructor
Returns:
A promise that resolves to an object of type: "PDFNet.OCMD"- Type
- Promise.<PDFNet.OCMD>
-
getOCGs()
-
Returns the optional-content groups listed under 'OCGs' entry in the object dictionary.
Returns:
A promise that resolves to a dictionary (for a single OCG::Group object), an SDF::Obj array (for multiple OCG::Group objects) or NULL (for an empty OCMD).- Type
- Promise.<PDFNet.Obj>
-
getSDFObj()
-
Returns:
A promise that resolves to pointer to the underlying SDF/Cos object.- Type
- Promise.<PDFNet.Obj>
-
getVisibilityExpression()
-
Returns:
A promise that resolves to if the PDOCMD has a visibility expression entry, return the SDF::Obj array object representing the expression, otherwise returns NULL.- Type
- Promise.<PDFNet.Obj>
-
getVisibilityPolicy()
-
Returns the optional-content membership dictionary's visibility policy, which determines the visibility of content with respect to the ON-OFF state of OCGs listed in the dictionary.
Returns:
A promise that resolves to the visibility policy.- Type
- Promise.<number>
Example
Return value enum: <pre> PDFNet.OCMD.VisibilityPolicyType = { e_AllOn : 0 e_AnyOn : 1 e_AnyOff : 2 e_AllOff : 3 } </pre>
-
isCurrentlyVisible(ctx)
-
Parameters:
Name Type Description ctx
PDFNet.OCGContext The context in which the visibility of content is tested. Returns:
A promise that resolves to true if content tagged with this OCMD is visible in the given context, false if it is hidden.Based on the optional-content groups listed in the dictionary, the current ON-OFF state of those groups within the specified context, and the dictionary's visibility policy, test whether the content tagged with this dictionary would be visible.
- Type
- Promise.<boolean>
-
isValid()
-
Returns:
A promise that resolves to true if this is a valid (non-null) OCMD, false otherwise.- Type
- Promise.<boolean>
-
setVisibilityPolicy(vis_policy)
-
Sets the optional-content membership dictionary's visibility policy, which determines the visibility of content with respect to the ON-OFF state of OCGs listed in the dictionary.
Parameters:
Name Type Description vis_policy
number PDFNet.OCMD.VisibilityPolicyType = { e_AllOn : 0 e_AnyOn : 1 e_AnyOff : 2 e_AllOff : 3 }
New visibility policy.Returns:
- Type
- Promise.<void>