org.faceless.pdf2
Class PDFBookmark

java.lang.Object
  extended byorg.faceless.pdf2.PDFObject
      extended byorg.faceless.pdf2.PDFMap
          extended byorg.faceless.pdf2.PDFBookmark
All Implemented Interfaces:
Cloneable

public final class PDFBookmark
extends org.faceless.pdf2.PDFMap

This class describes the Bookmark or Outline part of a PDF document - the "Table of Contents" structure that allows easy navigation through the document.

Bookmarks are structured like a directory tree, with each node on the tree having zero or more children. The top of the tree is always the document itself.

Example

Here's an example of a simple bookmark tree, and the code that creates it.

 +-- Section 1 -+-- SubSection 1.1
 |              |
 |              +-- SubSection 1.2 
 |
 +-- Section 2
 
   PDF pdf = new PDF();

   // Add the top level bookmarks "Section 1" and "Section 2" to the document.
   List topbookmarks = pdf.getBookmarks();
   PDFBookmark s1 = new PDFBookmark("Section 1", someaction);
   PDFBookmark s2 = new PDFBookmark("Section 2", someaction);
   topbookmarks.add(s1);
   topbookmarks.add(s2);

   // Add the bookmarks under "Section 1"
   List s1bookmarks = s1.getBookmarks();
   PDFBookmark s11 = new PDFBookmark("SubSection 1.1", someaction);
   PDFBookmark s12 = new PDFBookmark("SubSection 1.2", someaction);
   s1bookmarks.add(s11);
   s1bookmarks.add(s12);
 

There is no limit to the number of bookmarks in a PDF document or to the level they are nested. To display the bookmarks when the document is first opened, see the PDF.setLayout(java.lang.String, java.lang.String) method.

Since:
1.0

Constructor Summary
PDFBookmark(String name, PDFAction action)
          Create a new bookmark with an initial state of "closed".
PDFBookmark(String name, PDFAction action, boolean open)
          Create a new bookmark and set the initial state to "open" or "closed"
 
Method Summary
 boolean equals(Object o)
           
 PDFAction getAction()
          Get the action this bookmark performs when selected
 List getBookmarks()
          Return the a List containing this bookmarks children.
 String getName()
          Get the name of this bookmark
 void setAction(PDFAction action)
          Set the action this bookmark performs when selected
 void setColor(Color c)
          Set the color of the Bookmark.
 void setName(String name)
          Set the name of this bookmark
 void setStyle(boolean italic, boolean bold)
          Set the style of the Bookmark to italic, bold or both.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDFBookmark

public PDFBookmark(String name,
                   PDFAction action)
Create a new bookmark with an initial state of "closed".

Parameters:
name - The name of the bookmark as seen by the user. May include Unicode characters.
action - the action to perform when the bookmark is selected

PDFBookmark

public PDFBookmark(String name,
                   PDFAction action,
                   boolean open)
Create a new bookmark and set the initial state to "open" or "closed"

Parameters:
name - The name of the bookmark as seen by the user. May include Unicode characters.
action - The action to perform when the bookmark is selected
open - Whether the bookmark is open by default
Since:
1.0.4
Method Detail

getBookmarks

public List getBookmarks()
Return the a List containing this bookmarks children. The list has zero or more elements of type PDFBookmark, and may be altered using any of the standard List methods.

Returns:
the list of bookmarks

setColor

public void setColor(Color c)
Set the color of the Bookmark. This feature is only available in Acrobat 5 or later (PDF 1.4), but should be safely ignored by earlier viewers.

Since:
1.1

setStyle

public void setStyle(boolean italic,
                     boolean bold)
Set the style of the Bookmark to italic, bold or both. This feature is only available in Acrobat 5 or later (PDF 1.4), but should be safely ignored by earlier viewers.

Since:
1.1

setAction

public void setAction(PDFAction action)
Set the action this bookmark performs when selected

Parameters:
action - the action to perform when the bookmark is activated - may be null
Since:
1.1.12

getAction

public PDFAction getAction()
Get the action this bookmark performs when selected

Returns:
the action performed when the bookmark is activated - may be null
Since:
1.1.12

setName

public void setName(String name)
Set the name of this bookmark

Parameters:
name - The name of the bookmark as seen by the user. May include Unicode characters.
Since:
1.1.12

getName

public String getName()
Get the name of this bookmark

Returns:
the name of the bookmark as seen by the user
Since:
1.1.12

toString

public String toString()

equals

public boolean equals(Object o)


Copyright © 2001-2004 Big Faceless Organization