public class PDFBookmarkIterator
extends java.lang.Object
PDFBookmarkIterator
represents a cursor for enumerating
the bookmark items of a PDF document.
It can be constructed by the following way.
Example:
PDFDocument document = PDFDocument.open(file,password); PDFBookmarkIterator iterator = document.createBookmarkIterator();
PDFDocument
Modifier and Type | Class and Description |
---|---|
static class |
PDFBookmarkIterator.BookmarkData
BookmarkData is an inner class defined for bookmark data
object. |
Modifier and Type | Field and Description |
---|---|
static int |
POS_FIRSTCHILD
Position of the first child.
|
static int |
POS_FIRSTSIBLING
Position of the first sibling.
|
static int |
POS_LASTCHILD
Position of the last child.
|
static int |
POS_LASTSIBLING
Position of the last sibling.
|
static int |
POS_NEXT
Position of the next sibling.
|
static int |
POS_PREVIOUS
Position of the previous sibling.
|
Modifier and Type | Method and Description |
---|---|
PDFBookmarkIterator |
cloneBookmark()
Clone an iterator to access bookmark in a document.
|
int |
countActions()
Count the actions of current bookmark item.
|
PDFAction |
getAction(int index)
Get the specified bookmark action.
|
PDFBookmarkIterator.BookmarkData |
getBookmarkData()
Get the current bookmark item's data.
|
BookmarkPos |
getPos()
Get the bookmark position handle from
PDFBookmarkIterator . |
boolean |
hasChild()
Check whether the current bookmark item has child node or not.
|
void |
insert(int position,
PDFBookmarkIterator.BookmarkData data)
Insert a new bookmark item at the position specified by index.
|
void |
insertAction(int index,
PDFAction action)
Insert bookmark action.
|
boolean |
insertAtPos(BookmarkPos newParentPos,
int childIndex)
Insert a bookmark to be the child (specified by index) of another
bookmark with specific position and original bookmark will be the next sibling.
|
boolean |
isFirstChild()
Check whether the current bookmark item is the first child of its
parent or not.
|
boolean |
isLastChild()
Check whether the current bookmark item is the last child of its
parent or not.
|
boolean |
isRoot()
Check whether the current bookmark item is root or not.
|
boolean |
moveToFirstChild()
Move the cursor to its first child if exists.
|
boolean |
moveToNextSibling()
Move the cursor to its next sibling if exists.
|
boolean |
moveToParent()
Move the cursor to its parent if exists.
|
boolean |
moveToPos(BookmarkPos position)
Move the cursor to a position specified by a
BookmarkPos object. |
boolean |
moveToPrevSibling()
Move the cursor to its previous sibling if exists.
|
void |
moveToRoot()
Move the cursor to the root of PDF bookmark.
|
void |
release()
Release a
PDFBookmarkIterator object. |
void |
remove()
Remove the current bookmark item.
|
boolean |
removeAction(int index)
Remove a specific bookmark action.
|
boolean |
removeAllActions()
Remove all bookmark actions.
|
boolean |
setAction(int index,
PDFAction action)
Set bookmark action.
|
void |
setBookmarkData(PDFBookmarkIterator.BookmarkData data)
Set data to the current bookmark.
|
boolean |
update()
Update specific bookmark iterator object after object of bookmark tree
has been changed.
|
public static final int POS_FIRSTCHILD
public static final int POS_LASTCHILD
public static final int POS_PREVIOUS
public static final int POS_NEXT
public static final int POS_FIRSTSIBLING
public static final int POS_LASTSIBLING
public void moveToRoot() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean moveToFirstChild() throws PDFException
true
if moved successfully, else return
false
if the current bookmark item has no child.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean moveToNextSibling() throws PDFException
true
if moved successfully, else return
false
if the current bookmark item has no next
sibling.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean moveToParent() throws PDFException
true
if moved successfully, else return
false
if the current bookmark item has no parent.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean moveToPrevSibling() throws PDFException
true
if moved successfully, else return
false
if the current bookmark item has no previous
sibling.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean moveToPos(BookmarkPos position) throws PDFException
BookmarkPos
object.position
- The new position of bookmark.true
if moved successfully,else return
false
if the new position is invalid.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
BookmarkPos
public boolean isRoot() throws PDFException
boolean
value to indicate whether the current bookmark
item is root or not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean isLastChild() throws PDFException
boolean
value to indicate whether the bookmark
item is the last child of its parent or not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean isFirstChild() throws PDFException
boolean
value to indicate whether the current
bookmark item is the first child of its parent or not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean hasChild() throws PDFException
boolean
value to indicate whether the current
bookmark item has child node or not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int countActions() throws PDFException
integer
value that receives action counts.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFAction getAction(int index) throws PDFException
index
- An integer
value specifies index of
PDFAction
object.PDFAction
object by index.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFAction
public PDFBookmarkIterator.BookmarkData getBookmarkData() throws PDFException
BookmarkData
object to receive the bookmark data.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFBookmarkIterator.BookmarkData
public void setBookmarkData(PDFBookmarkIterator.BookmarkData data) throws PDFException
data
- A BookmarkData
object to be set.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFBookmarkIterator.BookmarkData
public void insert(int position, PDFBookmarkIterator.BookmarkData data) throws PDFException
position
- An integer
value specified position where the new
bookmark item to be inserted. It should be one of these constants
POS_XXX
data
- A BookmarkData
object to be inserted.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFBookmarkIterator.BookmarkData
public void remove() throws PDFException
If the current bookmark has a next sibling, after deleted, cursor will point to it. Otherwise, cursor will point to the deleted bookmark's parent. Root cannot be deleted.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFBookmarkIterator.BookmarkData
public boolean setAction(int index, PDFAction action) throws PDFException
index
- An integer
value specified position where the
action to be set. Range: 0 to (actioncount-1).
actioncount
is returned by function
countActions()
.action
- A PDFAction
object to be set.true
if set the specified action successfully, else
return false
for the parameter index
is
out of range.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFAction
public void insertAction(int index, PDFAction action) throws PDFException
index
- An integer
value specified Position where the new
action to be insert. The bookmark action will be inserted to
the last position if the index
is out of range.action
- A PDFAction
object to be insert.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFAction
public boolean removeAction(int index) throws PDFException
index
- An integer
value specified position where the
action to be removed.true
if removed the specified action successfully,
else return false
for not found the specified
action.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean removeAllActions() throws PDFException
true
if removed successfully, else return
false
for failure.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFBookmarkIterator cloneBookmark() throws PDFException
PDFBookmarkIterator
object that receives cloned
iterator object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void release() throws PDFException
PDFBookmarkIterator
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean update() throws PDFException
Object of bookmark tree may be changed by adding a new bookmark node,
removing a existed bookmark node, or moving a bookmark node to a new place.
After these changes, the application should call this function to
update bookmark iterators which are kept by application and are not used
directly in these changes. If the bookmark node has been removed, and the
bookmark iterator will be set to root and this function will throws a
exception.PDFException.ERRCODE_NOTFOUND
true
if updated the current bookmark iterator
successfully, else return false
for any other
errors.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean insertAtPos(BookmarkPos newParentPos, int childIndex) throws PDFException
newParentPos
- A BookmarkPos
object which specific the position
of new parent bookmark.childIndex
- Index of child, which indicates where the bookmark iterator
should be inserted under newParentPos
. If this is
below 0, bookmark iterator will be set to be the first child.
If this is above current children count of new parent
bookmark, bookmark iterator will be set to be the last child.true
if inserted successfully, else return
false
for failure.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
BookmarkPos
public BookmarkPos getPos() throws PDFException
PDFBookmarkIterator
.BookmarkPos
object that receives the bookmark
position object. If not found, it will return
null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
BookmarkPos