public class Context
extends java.lang.Object
The OCG::Context object represents an optional-content context in a document, within which document objects such as words or annotations are visible or hidden. The context keeps track of the ON-OFF states of all of the optional-content groups (OCGs) in a document. Content is or is not visible with respect to the OCG states stored in a specific context. Unlike other objects in OCG namespace, the OCG::Context does not correspond to any explicit PDF structure.
Each PDFView has a default context (PDF::GetOCGContext()) that it uses for on-screen drawing and that determines the default state for any drawing. The context has flags that control whether to draw content that is marked as optional, and whether to draw content that is not marked as optional.
When enumerating page content, OCG::Context can be passed as a parameter in ElementReader.Begin() method. When using PDFDraw, PDFRasterizer, or PDFView class to render PDF pages use ( PDFDraw::SetOCGContext() method to select an OC context.
There can be more than one Context object, representing different combinations of OCG states. You can change the states of OCGs within any context. You can build contexts with your own combination of OCG states, and issue drawing or enumeration commands using that context. For example, you can pass an optional-content context to ElementReader.Begin(). You can save the resulting state information as part of the configuration (e.g. using Config::SetInit methods), but the context itself has no corresponding PDF representation, and is not saved.
Modifier and Type | Field and Description |
---|---|
static int |
e_AllOC
Draw or enumerate all optional content, regardless of its visibility state.
|
static int |
e_NoOC
Draw or enumerate no optional content, regardless of its visibility state.
|
static int |
e_VisibleOC
Draw or enumerate optional content that is visible, according to the current state of
Optional Content Groups (OCGs) and Optional Content Membership Dictionaries (OCMDs).
|
Constructor and Description |
---|
Context(Config config)
Create a context object that represents an optional-content state of the
document from a given configuration.
|
Context(Context context)
create a copy from another Context object
|
Modifier and Type | Method and Description |
---|---|
static Context |
__Create(long impl,
java.lang.Object ref) |
long |
__GetHandle() |
int |
getOCMode()
Get the OC mode.
|
boolean |
getState(Group group)
Get the state of the Context
|
void |
resetStates(boolean all_on)
Set the sates of all OCGs in the context to ON or OFF.
|
void |
setNonOCDrawing(boolean draw_non_OC)
Set the non-OC status for this context.
|
void |
setOCDrawMode(int oc_draw_mode)
Set the drawing and enumeration type for this context.
|
void |
setState(Group group,
boolean state)
Set the ON-OFF states for the given optional-content group (OCG) in this
context.
|
public static final int e_VisibleOC
public static final int e_AllOC
public static final int e_NoOC
public Context(Context context) throws PDFNetException
context
- Another context from which to take initial OCG states.PDFNetException
public Context(Config config) throws PDFNetException
config
- A configuration from which to take initial OCG states.PDFNetException
public boolean getState(Group group) throws PDFNetException
group
- The optional-content group (OCG) that is queried.PDFNetException
public void setState(Group group, boolean state) throws PDFNetException
group
- The optional-content group (OCG) that is queried.state
- true for 'ON' and false for 'OFF'.PDFNetException
public void resetStates(boolean all_on) throws PDFNetException
all_on
- A flag used to specify whether the OCG states should be set
to ON (if true), or OFF (if false).PDFNetException
public void setNonOCDrawing(boolean draw_non_OC) throws PDFNetException
draw_non_OC
- A flag specifying whether the content that is not
marked as optional should be treated as visible.PDFNetException
public void setOCDrawMode(int oc_draw_mode) throws PDFNetException
oc_draw_mode
- A flag specifying the visibility of optional content.PDFNetException
public int getOCMode() throws PDFNetException
PDFNetException
public long __GetHandle()
public static Context __Create(long impl, java.lang.Object ref)