Class PDOutlineNode
java.lang.Object
org.apache.pdfbox.pdmodel.common.PDDictionaryWrapper
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDDocumentOutline
,PDOutlineItem
Base class for a node in the outline of a PDF document.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFirst
(PDOutlineItem newChild) Adds the given node to the top of the children list.void
addLast
(PDOutlineItem newChild) Adds the given node to the bottom of the children list.private void
append
(PDOutlineItem newChild) Appends the child to the linked list of children.children()
void
Close this node.int
Get the number of open nodes or a negative number if this node is closed.(package private) PDOutlineItem
getOutlineItem
(COSName name) (package private) PDOutlineNode
boolean
boolean
void
openNode()
This will set this node to be open when it is shown in the viewer.private void
prepend
(PDOutlineItem newChild) Prepends the child to the linked list of children.(package private) void
(package private) void
setFirstChild
(PDOutlineNode outlineNode) Set the first child, this will be maintained by this class.(package private) void
setLastChild
(PDOutlineNode outlineNode) Set the last child, this will be maintained by this class.(package private) void
setOpenCount
(int openCount) Set the open count.(package private) void
setParent
(PDOutlineNode parent) private void
(package private) void
updateParentOpenCount
(int delta) The count parameter needs to be updated when you add, remove, open or close outline items.(package private) void
Methods inherited from class org.apache.pdfbox.pdmodel.common.PDDictionaryWrapper
equals, getCOSObject, hashCode
-
Constructor Details
-
PDOutlineNode
public PDOutlineNode()Default Constructor. -
PDOutlineNode
- Parameters:
dict
- The dictionary storage.
-
-
Method Details
-
getParent
PDOutlineNode getParent()- Returns:
- The parent of this node or null if there is no parent.
-
hasChildren
public boolean hasChildren()- Returns:
- true if the node has at least one child
-
getOutlineItem
-
getFirstChild
- Returns:
- The first child or null if there is no child.
-
getLastChild
- Returns:
- The last child or null if there is no child.
-
getOpenCount
public int getOpenCount()Get the number of open nodes or a negative number if this node is closed. See PDF Reference 32000-1:2008 table 152 and 153 for more details. This value is updated as you append children and siblings.- Returns:
- The Count attribute of the outline dictionary.
-
setOpenCount
void setOpenCount(int openCount) Set the open count. This number is automatically managed for you when you add items to the outline.- Parameters:
openCount
- The new open count.
-
openNode
public void openNode()This will set this node to be open when it is shown in the viewer. By default, when a new node is created it will be closed. This will do nothing if the node is already open. -
closeNode
public void closeNode()Close this node. -
switchNodeCount
private void switchNodeCount() -
isNodeOpen
public boolean isNodeOpen()- Returns:
- true if this node count is greater than zero, false otherwise.
-
updateParentOpenCount
void updateParentOpenCount(int delta) The count parameter needs to be updated when you add, remove, open or close outline items.- Parameters:
delta
- The amount to update by.
-
children
- Returns:
- An
Iterable
view of the items children
-