pdftron.PDF
Class Bookmark

java.lang.Object
  extended by pdftron.PDF.Bookmark

public class Bookmark
extends java.lang.Object

A %PDF document may optionally display a document outline on the screen, allowing the user to navigate interactively from one part of the document to another. The outline consists of a tree-structured hierarchy of Bookmarks (sometimes called outline items), which serve as a 'visual table of contents' to display the document’s structure to the user. Each Bookmark has a title that appears on screen, and an Action that specifies what happens when a user clicks on the Bookmark. The typical action for a user-created Bookmark is to move to another location in the current document, although any action (see PDF::Action) can be specified. Bookmark is a utility class used to simplify work with %PDF bookmarks (or outlines; see section 8.2.2 'Document Outline' in %PDF Reference Manual for more details).


Constructor Summary
Bookmark()
          A constructor.
Bookmark(Obj in_bookmark_dict)
          A constructor.
 
Method Summary
 void addChild(Bookmark in_bookmark)
          Adds the specified Bookmark as the new last child of this Bookmark.
 Bookmark addChild(java.lang.String in_title)
          Adds a new Bookmark as the new last child of this Bookmark.
 void addNext(Bookmark in_bookmark)
          Adds the specified Bookmark as the new right sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.
 Bookmark addNext(java.lang.String in_title)
          Adds a new Bookmark to the tree containing this Bookmark, as the new right sibling.
 void addPrev(Bookmark in_bookmark)
          Adds the specified Bookmark as the new left sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.
 Bookmark addPrev(java.lang.String in_title)
          Adds a new Bookmark to the tree containing this Bookmark, as the new left sibling.
static Bookmark create(PDFDoc in_doc, java.lang.String in_title)
          Creates a new valid Bookmark with given title in the specified document.
 void delete()
          Removes the Bookmark's subtree from the bookmark tree containing it.
 boolean equals(java.lang.Object b)
          Compares two Bookmark objects for equality.
 Bookmark find(java.lang.String in_title)
          Get the Bookmark specified by the given title string.
 Action getAction()
          Get the Bookmark's action.
 double[] getColor()
          Get the Bookmark's RGB color value.
 Bookmark getFirstChild()
          Returns the Bookmark's first child.
 int getFlags()
          Get the Bookmark's flags.
 int getIndent()
          Get the indentation level of the Bookmark in its containing tree.
 Bookmark getLastChild()
          Returns the Bookmark's last child.
 Bookmark getNext()
          Returns the Bookmark's next (right) sibling.
 int getOpenCount()
          Get the number of opened bookmarks in this subtree.
 Bookmark getParent()
          Returns the Bookmark's parent Bookmark.
 Bookmark getPrev()
          Returns the Bookmark's previous (left) sibling.
 Obj getSDFObj()
          Returns the underlying SDF/Cos object.
 java.lang.String getTitle()
          Get the Bookmark's title string.
 Obj getTitleObj()
          Get the Bookmark's title string object.
 boolean hasChildren()
          Indicates whether the Bookmark has children.
 int hashCode()
           
 boolean isOpen()
          Indicates whether the Bookmark is open.
 boolean isValid()
          Indicates whether the Bookmark is valid (non-null).
 void removeAction()
          Removes the Bookmark’s action.
 void setAction(Action in_action)
          Set the Bookmark’s action.
 void setColor()
          Set Bookmark's text to black.
 void setColor(double in_r, double in_g, double in_b)
          Set Bookmark's text to specified color in RGB value
 void setFlags(int in_flags)
          Set the Bookmark's flags.
 void setOpen(boolean in_open)
          Open or close the Bookmark.
 void setTitle(java.lang.String title)
          Set the Bookmark’s title string.
 void unlink()
          Unlinks this Bookmark from the bookmark tree that contains it, and adjusts the tree appropriately.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bookmark

public Bookmark()
A constructor. Creates a null (non-valid) bookmark.


Bookmark

public Bookmark(Obj in_bookmark_dict)
A constructor. Creates a Bookmark and initialize it using given Cos/SDF object.

Parameters:
in_bookmark_dict - Pointer to the Cos/SDF object (outline item dictionary).
Note:
The constructor does not copy any data, but is instead the logical equivalent of a type cast.
Method Detail

create

public static Bookmark create(PDFDoc in_doc,
                              java.lang.String in_title)
                       throws PDFNetException
Creates a new valid Bookmark with given title in the specified document.

Parameters:
in_doc - The document in which a Bookmark is to be created.
in_title - The title string value of the new Bookmark.
Returns:
The new Bookmark.
Throws:
PDFNetException
Note:
The new Bookmark is not linked to the outline tree. Use AddChild()/AddNext()/AddPrev() methods in order to link the Bookmark to the outline tree

equals

public boolean equals(java.lang.Object b)
Compares two Bookmark objects for equality.

Overrides:
equals in class java.lang.Object
Parameters:
b - the b
Returns:
True if the both Bookmarks share the same underlying SDF/Cos object; otherwise false.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isValid

public boolean isValid()
                throws PDFNetException
Indicates whether the Bookmark is valid (non-null).

Returns:
True if this is a valid (non-null) Bookmark; otherwise false.
Throws:
PDFNetException
Note:
If this method returns false the underlying SDF/Cos object is null and the Bookmark object should be treated as null as well.

hasChildren

public boolean hasChildren()
                    throws PDFNetException
Indicates whether the Bookmark has children.

Returns:
True if the Bookmark has children; otherwise false.
Throws:
PDFNetException

getNext

public Bookmark getNext()
                 throws PDFNetException
Returns the Bookmark's next (right) sibling.

Returns:
The Bookmark’s next (right) sibling.
Throws:
PDFNetException

getPrev

public Bookmark getPrev()
                 throws PDFNetException
Returns the Bookmark's previous (left) sibling.

Returns:
The Bookmark’s previous (left) sibling.
Throws:
PDFNetException

getFirstChild

public Bookmark getFirstChild()
                       throws PDFNetException
Returns the Bookmark's first child.

Returns:
The Bookmark’s first child.
Throws:
PDFNetException

getLastChild

public Bookmark getLastChild()
                      throws PDFNetException
Returns the Bookmark's last child.

Returns:
The Bookmark’s last child.
Throws:
PDFNetException

getParent

public Bookmark getParent()
                   throws PDFNetException
Returns the Bookmark's parent Bookmark.

Returns:
The Bookmark’s parent Bookmark.
Throws:
PDFNetException

find

public Bookmark find(java.lang.String in_title)
              throws PDFNetException
Get the Bookmark specified by the given title string.

Parameters:
in_title - The title string value of the Bookmark to find.
Returns:
A Bookmark matching the title string value specified.
Throws:
PDFNetException

addChild

public Bookmark addChild(java.lang.String in_title)
                  throws PDFNetException
Adds a new Bookmark as the new last child of this Bookmark.

Parameters:
in_title - The title string value of the new Bookmark.
Returns:
The newly created child Bookmark.
Throws:
PDFNetException
Note:
If this Bookmark previously had no children, it will be open after the child is added.

addChild

public void addChild(Bookmark in_bookmark)
              throws PDFNetException
Adds the specified Bookmark as the new last child of this Bookmark.

Parameters:
in_bookmark - The Bookmark object to be added as a last child of this Bookmark.
Throws:
PDFNetException
Note:
Parameter in_bookmark must not be linked to a bookmark tree., If this Bookmark previously had no children, it will be open after the child is added.

addNext

public Bookmark addNext(java.lang.String in_title)
                 throws PDFNetException
Adds a new Bookmark to the tree containing this Bookmark, as the new right sibling.

Parameters:
in_title - The title string value of the new Bookmark.
Returns:
The newly created sibling Bookmark.
Throws:
PDFNetException

addNext

public void addNext(Bookmark in_bookmark)
             throws PDFNetException
Adds the specified Bookmark as the new right sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.

Parameters:
in_bookmark - The Bookmark object to be added to this Bookmark.
Throws:
PDFNetException
Note:
Parameter in_bookmark must not be linked to a bookmark tree.

addPrev

public Bookmark addPrev(java.lang.String in_title)
                 throws PDFNetException
Adds a new Bookmark to the tree containing this Bookmark, as the new left sibling.

Parameters:
in_title - The title string value of the new Bookmark.
Returns:
The newly created sibling Bookmark.
Throws:
PDFNetException

addPrev

public void addPrev(Bookmark in_bookmark)
             throws PDFNetException
Adds the specified Bookmark as the new left sibling to this Bookmark, adjusting the tree containing this Bookmark appropriately.

Parameters:
in_bookmark - The Bookmark object to be added to this Bookmark.
Throws:
PDFNetException
Note:
Parameter in_bookmark must not be linked to a bookmark tree.

delete

public void delete()
            throws PDFNetException
Removes the Bookmark's subtree from the bookmark tree containing it.

Throws:
PDFNetException

unlink

public void unlink()
            throws PDFNetException
Unlinks this Bookmark from the bookmark tree that contains it, and adjusts the tree appropriately.

Throws:
PDFNetException
Note:
After the bookmark is unlinked is can be moved to another place in the bookmark tree located in the same document.

getIndent

public int getIndent()
              throws PDFNetException
Get the indentation level of the Bookmark in its containing tree.

Returns:
The indentation level of the Bookmark in its containing tree.
Throws:
PDFNetException
Note:
The root level has an indentation level of zero.

isOpen

public boolean isOpen()
               throws PDFNetException
Indicates whether the Bookmark is open.

Returns:
True if this Bookmark is open; otherwise false.
Throws:
PDFNetException
Note:
An open Bookmark shows all its children.

setOpen

public void setOpen(boolean in_open)
             throws PDFNetException
Open or close the Bookmark.

Parameters:
in_open - Boolean value that contains the status. If true, the Bookmark is opened. Otherwise the Bookmark is closed.
Throws:
PDFNetException
Note:
An opened Bookmark shows its children, while a closed Bookmark does not.

getOpenCount

public int getOpenCount()
                 throws PDFNetException
Get the number of opened bookmarks in this subtree.

Returns:
The number of opened bookmarks in this subtree (not including this Bookmark). If the item is closed, a negative integer whose absolute value specifies how many descendants would appear if the item were reopened.
Throws:
PDFNetException

getTitle

public java.lang.String getTitle()
                          throws PDFNetException
Get the Bookmark's title string.

Returns:
The Bookmark’s title string).
Throws:
PDFNetException

getTitleObj

public Obj getTitleObj()
                throws PDFNetException
Get the Bookmark's title string object.

Returns:
The Bookmark's title string object.
Throws:
PDFNetException

setTitle

public void setTitle(java.lang.String title)
              throws PDFNetException
Set the Bookmark’s title string.

Parameters:
title - The new title string for the bookmark.
Throws:
PDFNetException

getAction

public Action getAction()
                 throws PDFNetException
Get the Bookmark's action.

Returns:
The bookmark’s action.
Throws:
PDFNetException

setAction

public void setAction(Action in_action)
               throws PDFNetException
Set the Bookmark’s action.

Parameters:
in_action - The new Action for the Bookmark.
Throws:
PDFNetException

removeAction

public void removeAction()
                  throws PDFNetException
Removes the Bookmark’s action.

Throws:
PDFNetException

getFlags

public int getFlags()
             throws PDFNetException
Get the Bookmark's flags.

Returns:
The flags of the Bookmark object. Bit 1 (least-significant bit) indicates italic font whereas bit 2 indicates bold font. Therefore, 0 indicates normal, 1 is italic, 2 is bold, and 3 is bold-italic.
Throws:
PDFNetException

setFlags

public void setFlags(int in_flags)
              throws PDFNetException
Set the Bookmark's flags.

Parameters:
in_flags - The new bookmark flags. Bit 1 (the least-significant bit) indicates italic font whereas bit 2 indicates bold font. Therefore, 0 indicates normal, 1 is italic, 2 is bold, and 3 is bold-italic.
Throws:
PDFNetException

getColor

public double[] getColor()
                  throws PDFNetException
Get the Bookmark's RGB color value.

Returns:
RGB color value in a array
Throws:
PDFNetException
Note:
The three numbers out_r, out_g, and out_b are in the range 0.0 to 1.0, representing the components in the DeviceRGB color space of the color to be used for the Bookmark’s text.

setColor

public void setColor()
              throws PDFNetException
Set Bookmark's text to black.

Throws:
PDFNetException

setColor

public void setColor(double in_r,
                     double in_g,
                     double in_b)
              throws PDFNetException
Set Bookmark's text to specified color in RGB value

Parameters:
in_r - the red component in the DeviceRGB color space
in_g - the green component in the DeviceRGB color space
in_b - the blue component in the DeviceRGB color space
Throws:
PDFNetException

getSDFObj

public Obj getSDFObj()
Returns the underlying SDF/Cos object.

Returns:
The underlying SDF/Cos object.
Note:
A null (non-valid) bookmark returns a null object.


© 2002-2011 PDFTron Systems Inc.