Top Description Inners Fields Constructors Methods
org.apache.pdfbox.pdmodel.graphics.optionalcontent

public Class PDOptionalContentProperties

extends Object
implements COSObjectable
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.common.COSObjectable
Imports
java.util.ArrayList, .Collection, org.apache.pdfbox.cos.COSArray, .COSBase, .COSDictionary, .COSName, .COSObject, org.apache.pdfbox.pdmodel.common.COSObjectable

This class represents the optional content properties dictionary.
Since
PDF 1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
PDOptionalContentProperties.BaseState

Enumeration for the BaseState dictionary entry on the "D" dictionary.

Field Summary

Modifier and TypeField and Description
private final COSDictionary

Constructor Summary

AccessConstructor and Description
public
PDOptionalContentProperties()

Creates a new optional content properties dictionary.

public
PDOptionalContentProperties(COSDictionary
the dictionary
props
)

Creates a new instance based on a given COSDictionary.

Method Summary

Modifier and TypeMethod and Description
public void
addGroup(PDOptionalContentGroup
the optional content group
ocg
)

Adds an optional content group (OCG).

public PDOptionalContentProperties.BaseState

Returns:

the base state
getBaseState
()

Returns the base state for optional content groups.

public COSDictionary
getCOSObject()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

Convert this standard java object to a COS object.

private COSDictionary
getD()

public PDOptionalContentGroup

Returns:

the optional content group or null, if there is no such group
getGroup
(String
the group name
name
)

Returns the first optional content group of the given name.

public String[]

Returns:

an array of all names
getGroupNames
()

Lists all optional content group names.

private COSArray
public Collection<PDOptionalContentGroup>

Returns:

the optional content groups
getOptionalContentGroups
()

Returns the collection of all optional content groups.

public boolean

Returns:

true if the group exists, false otherwise
hasGroup
(String
the group name
groupName
)

Indicates whether a particular optional content group is found in the PDF file.

public boolean

Returns:

true if at least one group is enabled
isGroupEnabled
(String
the group name
groupName
)

Indicates whether at least one optional content group with this name is enabled.

public boolean

Returns:

true if the group is enabled
isGroupEnabled
(PDOptionalContentGroup
the group object
group
)

Indicates whether an optional content group is enabled.

public void
setBaseState(PDOptionalContentProperties.BaseState
the base state
state
)

Sets the base state for optional content groups.

public boolean

Returns:

true if at least one group with this name already had an on or off setting, false otherwise
setGroupEnabled
(String
the group name
groupName
,
boolean
true to enable, false to disable
enable
)

Enables or disables all optional content groups with the given name.

public boolean

Returns:

true if the group already had an on or off setting, false otherwise
setGroupEnabled
(PDOptionalContentGroup
the group object
group
,
boolean
true to enable, false to disable
enable
)

Enables or disables an optional content group.

private COSDictionary
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dictback to summary
private final COSDictionary dict

Constructor Detail

PDOptionalContentPropertiesback to summary
public PDOptionalContentProperties()

Creates a new optional content properties dictionary.

PDOptionalContentPropertiesback to summary
public PDOptionalContentProperties(COSDictionary props)

Creates a new instance based on a given COSDictionary.

Parameters
props:COSDictionary

the dictionary

Method Detail

addGroupback to summary
public void addGroup(PDOptionalContentGroup ocg)

Adds an optional content group (OCG).

Parameters
ocg:PDOptionalContentGroup

the optional content group

getBaseStateback to summary
public PDOptionalContentProperties.BaseState getBaseState()

Returns the base state for optional content groups.

Returns:PDOptionalContentProperties.BaseState

the base state

getCOSObjectback to summary
public COSDictionary getCOSObject()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

Doc from org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

Convert this standard java object to a COS object.

Returns:COSDictionary

The cos object that matches this Java object.

Annotations
@Override
getDback to summary
private COSDictionary getD()
getGroupback to summary
public PDOptionalContentGroup getGroup(String name)

Returns the first optional content group of the given name.

Parameters
name:String

the group name

Returns:PDOptionalContentGroup

the optional content group or null, if there is no such group

getGroupNamesback to summary
public String[] getGroupNames()

Lists all optional content group names.

Returns:String[]

an array of all names

getOCGsback to summary
private COSArray getOCGs()
getOptionalContentGroupsback to summary
public Collection<PDOptionalContentGroup> getOptionalContentGroups()

Returns the collection of all optional content groups.

Returns:Collection<PDOptionalContentGroup>

the optional content groups

hasGroupback to summary
public boolean hasGroup(String groupName)

Indicates whether a particular optional content group is found in the PDF file.

Parameters
groupName:String

the group name

Returns:boolean

true if the group exists, false otherwise

isGroupEnabledback to summary
public boolean isGroupEnabled(String groupName)

Indicates whether at least one optional content group with this name is enabled. There may be disabled optional content groups with this name even if this function returns true.

Parameters
groupName:String

the group name

Returns:boolean

true if at least one group is enabled

isGroupEnabledback to summary
public boolean isGroupEnabled(PDOptionalContentGroup group)

Indicates whether an optional content group is enabled.

Parameters
group:PDOptionalContentGroup

the group object

Returns:boolean

true if the group is enabled

setBaseStateback to summary
public void setBaseState(PDOptionalContentProperties.BaseState state)

Sets the base state for optional content groups.

Parameters
state:PDOptionalContentProperties.BaseState

the base state

setGroupEnabledback to summary
public boolean setGroupEnabled(String groupName, boolean enable)

Enables or disables all optional content groups with the given name.

Parameters
groupName:String

the group name

enable:boolean

true to enable, false to disable

Returns:boolean

true if at least one group with this name already had an on or off setting, false otherwise

setGroupEnabledback to summary
public boolean setGroupEnabled(PDOptionalContentGroup group, boolean enable)

Enables or disables an optional content group.

Parameters
group:PDOptionalContentGroup

the group object

enable:boolean

true to enable, false to disable

Returns:boolean

true if the group already had an on or off setting, false otherwise

toDictionaryback to summary
private COSDictionary toDictionary(COSBase o)
org.apache.pdfbox.pdmodel.graphics.optionalcontent back to summary

public final Enum PDOptionalContentProperties.BaseState

extends Enum<PDOptionalContentProperties.BaseState>
Class Inheritance

Enumeration for the BaseState dictionary entry on the "D" dictionary.

Field Summary

Modifier and TypeField and Description
private final COSName
public static final PDOptionalContentProperties.BaseState
OFF

The "OFF" value.

public static final PDOptionalContentProperties.BaseState
ON

The "ON" value.

public static final PDOptionalContentProperties.BaseState
UNCHANGED

The "Unchanged" value.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public COSName

Returns:

the name of the state
getName
()

Returns the PDF name for the state.

public static PDOptionalContentProperties.BaseState
public static PDOptionalContentProperties.BaseState

Returns:

the state enum value
valueOf
(COSName
the state name
state
)

Returns the base state represented by the given COSName.

public static PDOptionalContentProperties.BaseState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

nameback to summary
private final COSName name

Hides java.lang.Enum.name.

OFFback to summary
public static final PDOptionalContentProperties.BaseState OFF

The "OFF" value.

ONback to summary
public static final PDOptionalContentProperties.BaseState ON

The "ON" value.

UNCHANGEDback to summary
public static final PDOptionalContentProperties.BaseState UNCHANGED

The "Unchanged" value.

Constructor Detail

BaseStateback to summary
private BaseState(COSName value)

Method Detail

getNameback to summary
public COSName getName()

Returns the PDF name for the state.

Returns:COSName

the name of the state

valueOfback to summary
public static PDOptionalContentProperties.BaseState valueOf(String name)
valueOfback to summary
public static PDOptionalContentProperties.BaseState valueOf(COSName state)

Returns the base state represented by the given COSName.

Parameters
state:COSName

the state name

Returns:PDOptionalContentProperties.BaseState

the state enum value

valuesback to summary
public static PDOptionalContentProperties.BaseState[] values()