DL Logo

PDOCContext Enumerations

PDOCContextChangeTypes

Header: PDExpT.h:5750

Description

The optional-content group (OCG) state is changing.

Value options for PDOCContextChangeType.

Enum Constants

kPDOCGState
The OCGs' states are changing.
kPDOCContextDrawEnumType
The PDOCContext object's PDDrawEnumType is changing.
kPDOCContextNonOCDrawing
The PDOCContext object's non-optional content drawing is changing.
kPDOCContextIntent
The PDOCContext object's intent is changing.
kPDOCContextInit
The PDOCContext is being reset using PDOCContextInit().
kPDOC_LastContextChangeType=kPDOCContextInit

PDOCContextInitPolicies

Header: PDExpT.h:5679

Description

PDOCContextInitPolicy is used to specify how to initialize the states of Optional Content Groups (OCGs) when calling PDOCContextNew() or PDOCContextInit().

Enum Constants

kOCCInit_OFF
kOCCInit_ON
kOCCInit_FromOtherContext
kOCCInit_FromConfig

PDOCDrawEnumTypes

Header: PDExpT.h:5727

Description

    PDOCDrawEnumType controls drawing or enumerating the page with respect to optional content. It is an enumerated type that, together with the NonOCDrawing value, controls drawing or enumerating content on a page with optional content:
  • Content that is marked as optional content is drawn or not drawn according to the PDOCDrawEnumType and the visibility state as determined by the Optional Content Groups (OCGs) and OCMDs.
  • Content that is not marked as optional content is drawn when NonOCDrawing is true, and not drawn when NonOCDrawing is false.

Enum Constants

kPDOC_VisibleOC=0
Draw or enumerate optional content that is visible, according to the current state of Optional Content Groups (OCGs) and Optional Content Membership Dictionaries (OCMDs). This is the normal default mode.
kPDOC_AllOC
Draw or enumerate all optional content, regardless of its visibility state. If the context's NonOCDrawing is true, all contents of document are shown.
kPDOC_NoOC
Draw or enumerate no optional content, regardless of its visibility state. If the context's NonOCDrawing is false, nothing is drawn, resulting in a blank page.
kPDOC_LastDrawEnumType=kPDOC_NoOC

PDOCContext Typedefs

PDOCContext

Header: PDExpT.h:5649

Description

A PDOCContext is an object that keeps track the on/off states of all of the OCGs in a document. There can be more than one PDOCContext object, representing different combinations of OCG states. The PDDoc contains an internal PDOCContext that is used for on-screen drawing and as the default state used for any other drawing or content enumeration. Clients can change the states of OCGs within any PDOCContext. Clients can build (and save in the PDF file) PDOCContext objects with their own combination of OCG states, and issue drawing or enumeration commands using their own PDOCContext instead of the document's internal PDOCContext. All discussion of visibility of content is therefore meant to be with respect to the OCG states stored in a specific PDOCContext.

Syntax

typedef struct _t_PDOCContext *PDOCContext;

Returned From

Used By

Used In

PDOCContextChangeType

Header: PDExpT.h:5764

Description

The optional-content group (OCG) state is changing.

For value options see PDOCContextChangeTypes.

Syntax

typedef ASUns8 PDOCContextChangeType;

PDOCContextInitPolicy

Header: PDExpT.h:5689

Description

PDOCContextInitPolicy is used to specify how to initialize the states of Optional Content Groups (OCGs) when calling PDOCContextNew() or PDOCContextInit().

For value options see PDOCContextInitPolicies.

Syntax

typedef ASUns8 PDOCContextInitPolicy;

Used By

PDOCDrawEnumType

Header: PDExpT.h:5746

Description

    PDOCDrawEnumType controls drawing or enumerating the page with respect to optional content. It is an enumerated type that, together with the NonOCDrawing value, controls drawing or enumerating content on a page with optional content:
  • Content that is marked as optional content is drawn or not drawn according to the PDOCDrawEnumType and the visibility state as determined by the Optional Content Groups (OCGs) and OCMDs.
  • Content that is not marked as optional content is drawn when NonOCDrawing is true, and not drawn when NonOCDrawing is false.

Syntax

typedef ASUns8 PDOCDrawEnumType;

Returned From

Used By

PDOCContext Functions

PDOCContextApplyAutoStateChanges

Header: PDProcs.h:9749

Description

Calls PDOCContextFindAutoStateChanges() to find optional-content groups whose ON-OFF states should be toggled, based on usage application directives contained in the configuration's AS array, and applies the changes within the given context.

The AS array defines how usage entries are used to automatically manipulate the OCG states. It associates an event ( View, Print, or Export) with a list of OCGs and a category, or list of usage keys identifying OCG usage dictionary entries.

See the description of the Optional Content Groups (OCG) in the ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 8.11.2, page 222.

You can find this document on the web store of the International Standards Organization (ISO).

Syntax

ASBool PDOCContextApplyAutoStateChanges(PDOCContext ctx, PDOCConfig cfg, ASAtom event);

Parameters

ctx
The context for which the visibility state is changed.
cfg
The configuration whose usage directives are used.
event
The event for which an ON-OFF state is automatically changed. Events are View, Export, and Print.

Returns

true if successful, false otherwise.

PDOCContextClearAllUserOverrides

Header: PDProcs.h:10503

Description

Removes usage override marks in all optional-content groups in the given context.

When an optional-content group is marked as having had its state set explicitly in a specified context, automatic state changes caused by the View event are prevented. When a group's automatic state change is caused by the Export or Print event, the user-override setting for the group is ignored.

A configuration's AS array defines how usage entries are used to automatically manipulate the OCG states. It associates an event ( View, Print, or Export) with a list of OCGs and a category, or list of usage keys identifying OCG usage dictionary entries.

See the description of the Optional Content Groups (OCG) in the ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 8.11.2, page 222.

You can find this document on the web store of the International Standards Organization (ISO).

Syntax

void PDOCContextClearAllUserOverrides(PDOCContext ctx);

Parameters

ctx
The context for which the user override marks are removed.

PDOCContextContentIsVisible

Header: PDProcs.h:10006

Description

Tests whether content is visible in the optional-content context. The method considers the context's current OCMD stack, the group ON-OFF states, the non-OC drawing status, the drawing and enumeration type, and the intent.

Use this method in conjunction with the OCMD stack methods.

Syntax

ASBool PDOCContextContentIsVisible(PDOCContext ocContext);

Parameters

ocContext
The context for which the visibility state is desired.

Returns

true if the content is visible, false otherwise.

PDOCContextFindAutoStateChanges

Header: PDProcs.h:9717

Description

Finds optional-content groups whose ON-OFF states should be toggled in the context, based on usage application directives contained in the configuration's AS array.

The AS array defines how usage entries are used to automatically manipulate the OCG states. It associates an event ( View, Print, or Export) with a list of OCGs and a category, or list of usage keys identifying OCG usage dictionary entries.

Syntax

PDOCG *PDOCContextFindAutoStateChanges(PDOCContext ctx, PDOCConfig cfg, ASAtom event);

Parameters

ctx
The context for which the visibility state should be changed.
cfg
The configuration whose usage directives are used.
event
The event for which an ON-OFF state is automatically changed. Events are View, Export, and Print.

Returns

A NULL-terminated array of optional-content group objects. The client is responsible for freeing it using ASfree().

PDOCContextFree

Header: PDProcs.h:9520

Description

Destroys an optional-content context object and frees the associated memory as needed.

Syntax

void PDOCContextFree(PDOCContext ocContext);

Parameters

ocContext
The context object to free.

PDOCContextGetIntent

Header: PDProcs.h:9837

Description

Gets the intent list for an optional-content context. An intent is an ASAtom value broadly describing the intended use, 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.

Syntax

ASAtom *PDOCContextGetIntent(PDOCContext ocContext);

Parameters

ocContext
The context for which an intent is desired.

Returns

An array containing intent entries (ASAtom objects) terminated by ASAtomNull. The client is responsible for freeing it using ASfree().

PDOCContextGetNonOCDrawing

Header: PDProcs.h:9878

Description

Gets the non-OC drawing status for an optional-content context. Content that is not marked as optional content is drawn when NonOCDrawing is true, and not drawn when NonOCDrawing is false.

Together, this value and the PDOCDrawEnumType value of the context determine how both optional and non-optional content on a page is drawn or enumerated. See PDOCDrawEnumType().

Syntax

ASBool PDOCContextGetNonOCDrawing(PDOCContext ocContext);

Parameters

ocContext
The context for which the non-OC drawing status is desired.

Returns

true if the context's NonOCDrawing is true, false otherwise.

PDOCContextGetOCDrawEnumType

Header: PDProcs.h:9787

Description

Gets the drawing and enumeration type for an optional-content context. This type, together with the visibility determined by the OCG and Optional Content Membership Dictionary (OCMD) states, controls whether content that is marked as optional content is drawn or enumerated.

Together, this value and the NonOCDrawing value of the context determine how both optional and non-optional content on a page is drawn or enumerated. See PDOCDrawEnumType().

Syntax

PDOCDrawEnumType PDOCContextGetOCDrawEnumType(PDOCContext ocContext);

Parameters

ocContext
The context for which the drawing and enumeration type is desired.

Returns

The drawing and enumeration type value.

PDOCContextGetOCGStates

Header: PDProcs.h:9644

Description

Gets the ON-OFF states for the given optional-content groups (OCGs) in the given optional-content context. It returns the states in the states array, which must be large enough to hold as many ASBool values as there are OCGs.

Related Methods

Syntax

void PDOCContextGetOCGStates(PDOCContext ocContext, PDOCG *pdocgs, ASBool *states);

Parameters

ocContext
The context for which the OCG states are desired.
pdocgs
A NULL-terminated array of optional-content groups whose states are obtained.
states
(Filled by the method) An array of OCG states corresponding to the array of OCGs, true for ON and false for OFF. The array must be large enough to hold as many states as there are non- NULL OCGs.

PDOCContextGetPDDoc

Header: PDProcs.h:9544

Description

Gets the document that contains an optional-content context.

Related Methods

Syntax

PDDoc PDOCContextGetPDDoc(PDOCContext ocContext);

Parameters

ocContext
The context for which a document is desired.

Returns

The document object.

PDOCContextInit

Header: PDProcs.h:9563

Description

Initializes the ON-OFF states of all optional-content groups (OCGs) within an existing context.

Syntax

void PDOCContextInit(PDOCContext ocContext, PDOCContextInitPolicy policy, PDOCContext otherCtx, PDOCConfig pdOCCfg);

Parameters

ocContext
The context to initialize.
policy
The initialization policy for the context. This value determines whether optional-content groups are initially ON or OFF.
otherCtx
Another context from which to take initial OCG states when the policy is kOCCInit_FromOtherContext. It is ignored for other policies.
pdOCCfg
A configuration from which to take initial OCG states when the policy is kOCCInit_FromConfig. It is ignored for other policies.

PDOCContextMakeCopy

Header: PDProcs.h:9583

Description

Creates a new context object to represent an optional-content state of the document, using an existing context as a template.

This is the same as the following call:

PDOCCOntextNew(kOCCInit_FromOtherContext, ocContext, NULL, PDOCContextGetPDDoc(ocContext));

Syntax

PDOCContext PDOCContextMakeCopy(PDOCContext ocContext);

Parameters

ocContext
The context to copy.

Returns

The new PDOCContext object. The client is responsible for freeing the context using PDOCContextFree().

PDOCContextMakeCopyWithAutoStateChanges

Header: PDProcs.h:9690

Description

Creates a new context object that represents an optional-content state of the document, using an existing context as a template, but applying an automatic state change for the specified event. An automatic state change toggles all groups' ON-OFF states when the triggering event occurs.

A configuration's AS array defines how usage entries are used to automatically manipulate the OCG states. It associates an event ( View, Print, or Export) with a list of OCGs and a category, or list of usage keys identifying OCG usage dictionary entries.

Syntax

PDOCContext PDOCContextMakeCopyWithAutoStateChanges(PDOCContext inCtx, PDOCConfig cfg, ASAtom event);

Parameters

inCtx
The context to copy.
cfg
The configuration in which the automatic state change applies.
event
The event for which state will automatically change. Events are View, Export, and Print.

Returns

The new PDOCContext object. The client is responsible for freeing the context using PDOCContextFree().

PDOCContextNew

Header: PDProcs.h:9509

Description

Creates a context object that represents an optional-content state of the document, initializing it in the same way as PDOCContextInit().

Syntax

PDOCContext PDOCContextNew(PDOCContextInitPolicy policy, PDOCContext otherCtx, PDOCConfig pdOCCfg, PDDoc pdDoc);

Parameters

policy
The initialization policy for the new context. This value determines whether optional-content groups (OCGs) are initially ON or OFF.
otherCtx
Another context from which to take initial OCG states when the policy is kOCCInit_FromOtherContext. It is ignored for other policies.
pdOCCfg
A configuration from which to take initial OCG states when the policy is kOCCInit_FromConfig. It is ignored for other policies.
pdDoc
The document for which to create a context.

Returns

The new PDOCContext object. The client is responsible for freeing the context using PDOCContextFree().

PDOCContextNewWithInitialState

Header: PDProcs.h:9626

Description

Creates a context object that represents an optional-content state of the document, using the current state as the initial state for each group (OCG), as determined by the document's optional-content configuration (returned by PDDocGetOCConfig(pdDoc)).

Syntax

PDOCContext PDOCContextNewWithInitialState(PDDoc pdDoc);

Parameters

pdDoc
The document for which to create a context.

Returns

The new PDOCContext object. The client is responsible for freeing the context using PDOCContextFree().

PDOCContextNewWithOCDisabled

Header: PDProcs.h:9608

Description

Creates a context object that represents an optional-content state of the document, with the PDOCDrawEnumType property set to kPDOC_NoOC, so that no content marked as optional content is drawn, regardless of the visibility according to the OCGs and OCMDs.

Content that is not marked as optional content may still be drawn, depending on the NonOCDrawing property.

Syntax

PDOCContext PDOCContextNewWithOCDisabled(PDDoc pdDoc);

Parameters

pdDoc
The document for which to create a context.

Returns

The new PDOCContext object. The client is responsible for freeing the context using PDOCContextFree().

PDOCContextPopOCMD

Header: PDProcs.h:9986

Description

    Pops the optional-content membership dictionary (OCMD) stack for an optional-content context. The stack is used to track nesting of optional-content states as contents are enumerated or drawn:
  • Call the PDOCContextPushOCMD() method when entering BDC for optional content or beginning to process a form or annotation that has a OC entry.
  • Call this method to pop the stack when encountering EMC, or finishing the processing of a form or annotation appearance.

To track nested content that is not for optional content, pass in NULL for pdOCMD when pushing the OCMD stack for BMC, patterns, and charprocs, for BDC with no optional content, or for forms or annotations that do not have an OC entry. When finished processing any of these objects, you can call PDOCContextPopOCMD() without worrying about whether the content was optional.

Syntax

void PDOCContextPopOCMD(PDOCContext ocContext);

Parameters

ocContext
The context for which to pop the OCMD stack.

PDOCContextPushOCMD

Header: PDProcs.h:9954

Description

Pushes a new optional-content membership dictionary (OCMD) onto the stack for an optional-content context.

The stack is used to track nesting of optional-content states as contents are enumerated or drawn. Call this method when entering the BDC for optional content or beginning to process a form or annotation that has a OC entry. Call PDOCContextPopOCMD() when encountering an EMC, or finishing the processing of a form or annotation appearance.

To make it easier to track nested content that is not for optional content, pass NULL for pdOCMD when encountering BMC, patterns, and charprocs. Also pass NULL for a BDC with no optional content or for forms or annotations that do not have an OC entry. When finished processing any of these objects, you can call PDOCContextPopOCMD() without worrying about whether the content was optional.

Syntax

void PDOCContextPushOCMD(PDOCContext pdOCContext, PDOCMD pdOCMD);

Parameters

pdOCContext
The context containing the OCMD stack.
pdOCMD
The OCMD to push onto the stack.

PDOCContextResetOCMDStack

Header: PDProcs.h:9924

Description

Clears the Optional Content Membership Dictionary (OCMD) stack for an optional-content context, and resets the current visibility for the context based on the context's non-OC drawing setting (see PDOCContextSetNonOCDrawing()). Call this method at the start of an enumeration or drawing operation that uses a given context.

The OCMD stack contains optional-content membership dictionary objects. The OCMD stack methods and the various methods that test visibility (such as PDAnnotIsCurrentlyVisible()) work together as content is being enumerated or drawn to determine whether particular graphical elements are visible or not. Visibility is based on the context's collection of ON-OFF states for optional-content groups, the context's current settings for NonOCDrawing and PDOCDrawEnumType, and the state of the OCMD stack.

Any custom drawing or enumerating code that needs to keep track of visibility of content must make a private copy of the PDOCContext if that context could be accessed by some other client, in order to avoid conflicting state changes. In particular, you must copy the document's default context (as returned by PDDocGetOCContext()). To enforce this, this reset method does nothing when given a document's default context. Similarly, the push and pop stack operations raise an error for the default context.

If you are using the PD-level draw and enumeration methods, you do not need to copy the context or explicitly call the OCMD stack methods, as the PD-level methods do this internally.

Clients of PDFEdit and other libraries that enumerate contents need to use these three methods when traversing the PDEContent structure. When entering a new PDEContent, call PDOCContextPushOCMD() (passing an OCMD object or NULL). Upon finishing the traversal, call PDOCContextPopOCMD().

Syntax

void PDOCContextResetOCMDStack(PDOCContext pdOCContext);

Parameters

pdOCContext
The context for which to reset the OCMD stack.

PDOCContextSetIntent

Header: PDProcs.h:9813

Description

Sets the Intent entry in an optional-content context's Cos dictionary. An intent is an ASAtom value broadly describing the intended use, 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.

It raises an exception if the context is busy.

Syntax

void PDOCContextSetIntent(PDOCContext ocContext, ASAtom *intent);

Parameters

ocContext
The context for which to set the intent.
intent
The new Intent entry value, an array of atoms terminated with ASAtomNull.

PDOCContextSetNonOCDrawing

Header: PDProcs.h:9857

Description

Sets the non-OC status for an optional-content context. Content that is not marked as optional content is drawn when NonOCDrawing is true, and not drawn when NonOCDrawing is false.

Together, this value and the PDOCDrawEnumType value of the context determine how both optional and non-optional content on a page is drawn or enumerated. See PDOCDrawEnumType().

Syntax

void PDOCContextSetNonOCDrawing(PDOCContext ocContext, ASBool drawNonOC);

Parameters

ocContext
The context for which to set the non-OC drawing status.
drawNonOC
The new value for the non-OC drawing status, true or false.

PDOCContextSetOCDrawEnumType

Header: PDProcs.h:9768

Description

Sets the drawing and enumeration type for an optional-content context. This type, together with the visibility determined by the OCG and OCMD states, controls whether content that is marked as optional content is drawn or enumerated.

Together, this value and the NonOCDrawing value of the context determine how both optional and non-optional content on a page is drawn or enumerated. See PDOCDrawEnumType().

Syntax

void PDOCContextSetOCDrawEnumType(PDOCContext ocContext, PDOCDrawEnumType dt);

Parameters

ocContext
The context for which the drawing and enumeration type is desired.
dt
The new drawing and enumeration type.

PDOCContextSetOCGStates

Header: PDProcs.h:9662

Description

Sets the ON-OFF states for the given optional-content groups (OCGs) in the given optional-content context. The newStates array must be large enough to hold as many ASBool values as there are OCGs.

Related Methods

Syntax

void PDOCContextSetOCGStates(PDOCContext ocContext, PDOCG *pdocgs, ASBool *newStates);

Parameters

ocContext
The context for which the OCG states are set.
pdocgs
A NULL-terminated array of optional-content groups.
newStates
An array of new OCG states corresponding to the array of OCGs, true for ON and false for OFF. The array must contain as many states as there are non- NULL OCGs in the pdocgs array.

PDOCContextXObjectIsVisible

Header: PDProcs.h:10028

Description

Tests whether an XObject form or image contained in obj is visible in the optional-content context. The method considers the context's current OCMD stack, optional-content group ON-OFF states, the non-OC drawing status, the drawing and enumeration type, the intent, and the specific OCG.

Use this method in conjunction with the OCMD stack methods.

Syntax

ASBool PDOCContextXObjectIsVisible(PDOCContext pdOCContext, CosObj obj);

Parameters

pdOCContext
The context for which to test visibility.
obj
The external object.

Returns

true if the external object is visible, false otherwise.