Show / Hide Table of Contents

# Class OCMD

                <p> 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).

##### Inheritance

object
OCMD

##### Inherited Members

object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

###### Namespace: pdftron.PDF.OCG

###### Assembly: PDFNet.dll

##### Syntax

    public class OCMD

### Constructors

#### OCMD(Obj)

Creates a new optional-content group (OCG) object from an existing SDF/Cos object.

##### Declaration

    public OCMD(Obj ocmd)

##### Parameters

Type | Name | Description
--- | --- | ---
Obj | ocmd | the ocmd

### Methods

#### Create(PDFDoc, Obj, VisibilityPolicyType)

Creates a new optional-content membership dictionary (OCMD) object in the given document for the given groups and visibility policy.

##### Declaration

    public static OCMD Create(PDFDoc doc, Obj ocgs, OCMD.VisibilityPolicyType vis_policy)

##### Parameters

Type | Name | Description
--- | --- | ---
PDFDoc | doc | The document in which the new OCMD will be created.
Obj | ocgs | An array of optional-content groups (OCGs) to be members of the dictionary.
OCMD.VisibilityPolicyType | vis_policy | the vis_policy

##### Returns

Type | Description
--- | ---
OCMD | The newly created OCG::OCMD object.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetOCGs()

Gets the optional-content groups listed under 'OCGs' entry in the object dictionary.

##### Declaration

    public Obj GetOCGs()

##### Returns

Type | Description
--- | ---
Obj | An SDF::Obj array or OCG::Group objects or NULL is the array is not present.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetSDFObj()

Gets the SDFObj.

##### Declaration

    public Obj GetSDFObj()

##### Returns

Type | Description
--- | ---
Obj | Pointer to the underlying SDF/Cos object.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetVisibilityExpression()

Gets the visibility expression.

##### Declaration

    public Obj GetVisibilityExpression()

##### Returns

Type | Description
--- | ---
Obj | If the PDOCMD has a visibility expression entry, return the SDF::Obj array object representing the expression, otherwise returns NULL.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetVisibilityPolicy()

Gets 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.

##### Declaration

    public OCMD.VisibilityPolicyType GetVisibilityPolicy()

##### Returns

Type | Description
--- | ---
OCMD.VisibilityPolicyType | The visibility policy.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### IsCurrentlyVisible(Context)

Checks if is currently visible.

##### Declaration

    public bool IsCurrentlyVisible(Context context)

##### Parameters

Type | Name | Description
--- | --- | ---
Context | context | The context in which the visibility of content is tested.

##### Returns

Type | Description
--- | ---
bool | 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.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### IsValid()

Checks if is valid.

##### Declaration

    public bool IsValid()

##### Returns

Type | Description
--- | ---
bool | True if this is a valid (non-null) OCG, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### SetVisibilityPolicy(VisibilityPolicyType)

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.

##### Declaration

    public void SetVisibilityPolicy(OCMD.VisibilityPolicyType vis_policy)

##### Parameters

Type | Name | Description
--- | --- | ---
OCMD.VisibilityPolicyType | vis_policy | New visibility policy.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception