Class PDOptionalContentProperties
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentProperties
-
- All Implemented Interfaces:
COSObjectable
public class PDOptionalContentProperties extends java.lang.Object implements COSObjectable
This class represents the optional content properties dictionary.- Since:
- PDF 1.5
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PDOptionalContentProperties.BaseState
Enumeration for the BaseState dictionary entry on the "D" dictionary.
-
Field Summary
Fields Modifier and Type Field Description private COSDictionary
dict
-
Constructor Summary
Constructors Constructor Description PDOptionalContentProperties()
Creates a new optional content properties dictionary.PDOptionalContentProperties(COSDictionary props)
Creates a new instance based on a givenCOSDictionary
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGroup(PDOptionalContentGroup ocg)
Adds an optional content group (OCG).PDOptionalContentProperties.BaseState
getBaseState()
Returns the base state for optional content groups.COSDictionary
getCOSObject()
Convert this standard java object to a COS object.private COSDictionary
getD()
PDOptionalContentGroup
getGroup(java.lang.String name)
Returns the first optional content group of the given name.java.lang.String[]
getGroupNames()
Lists all optional content group names.private COSArray
getOCGs()
java.util.Collection<PDOptionalContentGroup>
getOptionalContentGroups()
Returns the collection of all optional content groups.boolean
hasGroup(java.lang.String groupName)
Indicates whether a particular optional content group is found in the PDF file.boolean
isGroupEnabled(java.lang.String groupName)
Indicates whether at least one optional content group with this name is enabled.boolean
isGroupEnabled(PDOptionalContentGroup group)
Indicates whether an optional content group is enabled.void
setBaseState(PDOptionalContentProperties.BaseState state)
Sets the base state for optional content groups.boolean
setGroupEnabled(java.lang.String groupName, boolean enable)
Enables or disables all optional content groups with the given name.boolean
setGroupEnabled(PDOptionalContentGroup group, boolean enable)
Enables or disables an optional content group.private COSDictionary
toDictionary(COSBase o)
-
-
-
Field Detail
-
dict
private final COSDictionary dict
-
-
Constructor Detail
-
PDOptionalContentProperties
public PDOptionalContentProperties()
Creates a new optional content properties dictionary.
-
PDOptionalContentProperties
public PDOptionalContentProperties(COSDictionary props)
Creates a new instance based on a givenCOSDictionary
.- Parameters:
props
- the dictionary
-
-
Method Detail
-
getCOSObject
public COSDictionary getCOSObject()
Convert this standard java object to a COS object.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The cos object that matches this Java object.
-
getOCGs
private COSArray getOCGs()
-
getD
private COSDictionary getD()
-
getGroup
public PDOptionalContentGroup getGroup(java.lang.String name)
Returns the first optional content group of the given name.- Parameters:
name
- the group name- Returns:
- the optional content group or null, if there is no such group
-
addGroup
public void addGroup(PDOptionalContentGroup ocg)
Adds an optional content group (OCG).- Parameters:
ocg
- the optional content group
-
getOptionalContentGroups
public java.util.Collection<PDOptionalContentGroup> getOptionalContentGroups()
Returns the collection of all optional content groups.- Returns:
- the optional content groups
-
getBaseState
public PDOptionalContentProperties.BaseState getBaseState()
Returns the base state for optional content groups.- Returns:
- the base state
-
setBaseState
public void setBaseState(PDOptionalContentProperties.BaseState state)
Sets the base state for optional content groups.- Parameters:
state
- the base state
-
getGroupNames
public java.lang.String[] getGroupNames()
Lists all optional content group names.- Returns:
- an array of all names
-
hasGroup
public boolean hasGroup(java.lang.String groupName)
Indicates whether a particular optional content group is found in the PDF file.- Parameters:
groupName
- the group name- Returns:
- true if the group exists, false otherwise
-
isGroupEnabled
public boolean isGroupEnabled(java.lang.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
- the group name- Returns:
- true if at least one group is enabled
-
isGroupEnabled
public boolean isGroupEnabled(PDOptionalContentGroup group)
Indicates whether an optional content group is enabled.- Parameters:
group
- the group object- Returns:
- true if the group is enabled
-
toDictionary
private COSDictionary toDictionary(COSBase o)
-
setGroupEnabled
public boolean setGroupEnabled(java.lang.String groupName, boolean enable)
Enables or disables all optional content groups with the given name.- Parameters:
groupName
- the group nameenable
- true to enable, false to disable- Returns:
- true if at least one group with this name already had an on or off setting, false otherwise
-
setGroupEnabled
public boolean setGroupEnabled(PDOptionalContentGroup group, boolean enable)
Enables or disables an optional content group.- Parameters:
group
- the group objectenable
- true to enable, false to disable- Returns:
- true if the group already had an on or off setting, false otherwise
-
-