PTOCMD

@interface PTOCMD : NSObject

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

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

    Declaration

    Objective-C

    + (PTOCMD *)Create:(PTPDFDoc *)doc
                  ocgs:(PTObj *)ocgs
            vis_policy:(PTVisibilityPolicyType)vis_policy;

    Swift

    class func create(_ doc: PTPDFDoc!, ocgs: PTObj!, vis_policy: PTVisibilityPolicyType) -> PTOCMD!

    Parameters

    doc

    The document in which the new OCMD will be created.

    ocgs

    An array of optional-content groups (OCGs) to be members of the dictionary.

    policy

    The visibility policy that determines the visibility of content with respect to the ON-OFF state of OCGs listed in the dictionary.

    Return Value

    The newly created OCG::OCMD object.

  • Creates a new optional-content group membership dictionary (OCMD) object from an existing SDF/Cos object.

    Declaration

    Objective-C

    - (instancetype)initWithOcmd:(PTObj *)ocmd;

    Swift

    init!(ocmd: PTObj!)
  • Declaration

    Objective-C

    - (BOOL)IsValid;

    Swift

    func isValid() -> Bool

    Return Value

    True if this is a valid (non-null) OCMD, false otherwise.

  • Returns the optional-content groups listed under ‘OCGs’ entry in the object dictionary.

    Declaration

    Objective-C

    - (PTObj *)GetOCGs;

    Swift

    func getOCGs() -> PTObj!

    Return Value

    A dictionary (for a single OCG::Group object), an SDF::Obj array (for multiple OCG::Group objects) or NULL (for an empty OCMD).

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

    Declaration

    Objective-C

    - (PTVisibilityPolicyType)GetVisibilityPolicy;

    Swift

    func getVisibilityPolicy() -> PTVisibilityPolicyType

    Return Value

    The visibility 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.

    Declaration

    Objective-C

    - (void)SetVisibilityPolicy:(PTVisibilityPolicyType)vis_policy;

    Swift

    func setVisibilityPolicy(_ vis_policy: PTVisibilityPolicyType)

    Parameters

    vis_policy

    New visibility policy.

  • Declaration

    Objective-C

    - (PTObj *)GetVisibilityExpression;

    Swift

    func getVisibilityExpression() -> PTObj!

    Return Value

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

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

    Declaration

    Objective-C

    - (BOOL)IsCurrentlyVisible:(PTContext *)context;

    Swift

    func isCurrentlyVisible(_ context: PTContext!) -> Bool

    Parameters

    context

    The context in which the visibility of content is tested.

    Return Value

    true if content tagged with this OCMD is visible in the given context, false if it is hidden.

  • Declaration

    Objective-C

    - (PTObj *)GetSDFObj;

    Swift

    func getSDFObj() -> PTObj!

    Return Value

    Pointer to the underlying SDF/Cos object.