Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.faceless.pdf2
Class PDFBookmark

    java.lang.Object
      org.faceless.pdf2.PDFBookmark

All Implemented Interfaces:
  Cloneable

    public final class PDFBookmark

extends Object

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
`PDFAction` | `getAction()` Get the action this bookmark performs when selected
`List` | `getBookmarks()` Return the a List containing this bookmarks children.
`Color` | `getColor()` Get the Color of the Bookmark, as set by `setColor(java.awt.Color)`.
`String` | `getName()` Get the name of this bookmark
`boolean` | `isBold()` Return true if the style of the bookmark (as set by `setStyle(boolean, boolean)` is bold, false otherwise.
`boolean` | `isItalic()` Return true if the style of the bookmark (as set by `setStyle(boolean, boolean)` is italic, false otherwise.
`boolean` | `isOpen()` Return whether this Bookmark is open.
`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` | `setOpen(boolean open)` Set whether the Bookmark is open
`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
`equals, 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

### getColor

    public Color getColor()

  Get the Color of the Bookmark, as set by `setColor(java.awt.Color)`. Returns `null` if no color is specified.

  Since:
    2.7.8

### 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

### isBold

    public boolean isBold()

  Return true if the style of the bookmark (as set by `setStyle(boolean, boolean)` is bold, false otherwise.

  Since:
    2.7.8

### isItalic

    public boolean isItalic()

  Return true if the style of the bookmark (as set by `setStyle(boolean, boolean)` is italic, false otherwise.

  Since:
    2.7.8

### isOpen

    public boolean isOpen()

  Return whether this Bookmark is open.

  Since:
    2.7.8
  See Also:
    `setOpen(boolean)`

### setOpen

    public void setOpen(boolean open)

  Set whether the Bookmark is open

  Since:
    2.7.8
  See Also:
    `isOpen()`

### 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()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 Big Faceless Organization