Show / Hide Table of Contents

# Class Context

Begin processing a page.

##### Inheritance

object
Context

##### Implements

IDisposable

##### 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 Context : IDisposable

##### Remarks

When page processing is completed, make sure to call ElementReader.End().

### Constructors

#### Context(Config)

Create a context object that represents an optional-content state of the document from a given configuration.

##### Declaration

    public Context(Config config)

##### Parameters

Type | Name | Description
--- | --- | ---
Config | config | A configuration from which to take initial OCG states.

##### Exceptions

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

#### Context(Context)

Copy constructor.

##### Declaration

    public Context(Context context)

##### Parameters

Type | Name | Description
--- | --- | ---
Context | context | Another context from which to take initial OCG states.

##### Exceptions

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

### Methods

#### Dispose()

Releases all resources used by the Context

##### Declaration

    public override sealed void Dispose()

##### Exceptions

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

#### Dispose(bool)

##### Declaration

    [HandleProcessCorruptedStateExceptions]
    protected virtual void Dispose(bool A_0)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | A_0 |

##### Exceptions

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

#### ~Context()

##### Declaration

    protected ~Context()

##### Exceptions

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

#### GetNonOCDrawing()

Gets the non oc drawing.

##### Declaration

    public bool GetNonOCDrawing()

##### Returns

Type | Description
--- | ---
bool | the non-OC status for this context. The flag indicates whether the content that is not marked as optional should be treated as visible. For more information, please see SetNonOCDrawing().

##### Exceptions

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

#### GetOCMode()

Gets OC drawing mode

##### Declaration

    public Context.OCDrawMode GetOCMode()

##### Returns

Type | Description
--- | ---
Context.OCDrawMode | OC drawing mode

##### Exceptions

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

#### GetState(Group)

Gets the state.

##### Declaration

    public bool GetState(Group group)

##### Parameters

Type | Name | Description
--- | --- | ---
Group | group | The optional-content group (OCG) that is queried.

##### Returns

Type | Description
--- | ---
bool | the ON-OFF states (true or false) for the given optional-content group (OCG) in this OC context.

##### Exceptions

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

#### ResetStates(bool)

Sets the states of all OCGs in the context to ON or OFF.

##### Declaration

    public void ResetStates(bool all_on)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | all_on | A flag used to specify whether the OCG states should be set to ON (if true), or OFF (if false).

##### Exceptions

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

#### SetNonOCDrawing(bool)

Sets the non-OC status for this context. Content that is not marked as optional content is drawn (or element.IsOCVisible()) when 'draw_non_OC' is true, and not drawn/visible otherwise.

##### Declaration

    public void SetNonOCDrawing(bool draw_non_OC)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | draw_non_OC | draw_non_OC A flag specifying whether the content that is not marked as optional should be treated as visible.

##### Exceptions

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

#### SetOCDrawMode(OCDrawMode)

Sets the drawing and enumeration type for this 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.

##### Declaration

    public void SetOCDrawMode(Context.OCDrawMode oc_draw_mode)

##### Parameters

Type | Name | Description
--- | --- | ---
Context.OCDrawMode | oc_draw_mode | A flag specifying the visibility of optional content.

##### Exceptions

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

#### SetState(Group, bool)

Sets the ON-OFF states for the given optional-content group (OCG) in this context.

##### Declaration

    public void SetState(Group group, bool state)

##### Parameters

Type | Name | Description
--- | --- | ---
Group | group | The optional-content group (OCG) that is queried.
bool | state | true for 'ON' and false for 'OFF'.

##### Exceptions

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

### Implements

IDisposable