gnu.jpdf
Class PDFOutline

java.lang.Object
  extended by gnu.jpdf.PDFObject
      extended by gnu.jpdf.PDFOutline
All Implemented Interfaces:
java.io.Serializable

public class PDFOutline
extends PDFObject
implements java.io.Serializable

This class manages the documents outlines (also known as bookmarks).

See Also:
Serialized Form

Field Summary
protected  PDFOutline parent
          For subentries, this points to it's parent outline
 
Fields inherited from class gnu.jpdf.PDFObject
objser, pdfDocument
 
Constructor Summary
protected PDFOutline()
          Constructs a PDF Outline object.
  PDFOutline(java.lang.String title, PDFPage dest)
          Constructs a PDF Outline object.
  PDFOutline(java.lang.String title, PDFPage dest, int l, int b, int r, int t)
          Constructs a PDF Outline object.
 
Method Summary
 void add(PDFOutline outline)
          This adds an already existing outline to this one.
 PDFOutline add(java.lang.String title, PDFPage dest)
          This method creates an outline, and attaches it to this one.
 PDFOutline add(java.lang.String title, PDFPage dest, int x, int y, int w, int h)
          This method creates an outline, and attaches it to this one.
protected  int descendants()
          Returns the total number of descendants below this one.
 java.util.Enumeration elements()
          Returns all outlines directly below this one.
protected  int getIndex(PDFOutline outline)
          This is called by children to find their position in this outlines tree.
protected  int getLast()
          Returns the last index in this outline
protected  PDFOutline getNode(int i)
          Returns the outline at a specified position.
 void write(java.io.OutputStream os)
          Writes the object to the output stream.
 
Methods inherited from class gnu.jpdf.PDFObject
getPDFDocument, getSerialID, getType, toArray, toString, writeEnd, writeStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected PDFOutline parent
For subentries, this points to it's parent outline

Constructor Detail

PDFOutline

protected PDFOutline()
Constructs a PDF Outline object. This method is used internally only.


PDFOutline

public PDFOutline(java.lang.String title,
                  PDFPage dest)
Constructs a PDF Outline object. When selected, the whole page is displayed.

Parameters:
title - Title of the outline
dest - The destination page

PDFOutline

public PDFOutline(java.lang.String title,
                  PDFPage dest,
                  int l,
                  int b,
                  int r,
                  int t)
Constructs a PDF Outline object. When selected, the specified region is displayed.

Parameters:
title - Title of the outline
dest - The destination page
l - left coordinate
b - bottom coordinate
r - right coordinate
t - top coordinate
Method Detail

add

public PDFOutline add(java.lang.String title,
                      PDFPage dest)
This method creates an outline, and attaches it to this one. When the outline is selected, the entire page is displayed.

This allows you to have an outline for say a Chapter, then under the chapter, one for each section. You are not really limited on how deep you go, but it's best not to go below say 6 levels, for the reader's sake.

Parameters:
title - Title of the outline
dest - The destination page
Returns:
PDFOutline object created, for creating sub-outlines

add

public PDFOutline add(java.lang.String title,
                      PDFPage dest,
                      int x,
                      int y,
                      int w,
                      int h)
This method creates an outline, and attaches it to this one. When the outline is selected, the supplied region is displayed.

Note: the coordiates are in Java space. They are converted to User space.

This allows you to have an outline for say a Chapter, then under the chapter, one for each section. You are not really limited on how deep you go, but it's best not to go below say 6 levels, for the reader's sake.

Parameters:
title - Title of the outline
dest - The destination page
x - coordinate of region in Java space
y - coordinate of region in Java space
w - width of region in Java space
h - height of region in Java space
Returns:
PDFOutline object created, for creating sub-outlines

add

public void add(PDFOutline outline)
This adds an already existing outline to this one.

Note: the outline must have been added to the PDF document before calling this method. Normally the other add methods are used.

Parameters:
outline - PDFOutline to add

write

public void write(java.io.OutputStream os)
           throws java.io.IOException
Description copied from class: PDFObject

Writes the object to the output stream. This method must be overidden.

Note: It should not write any other objects, even if they are it's Kids, as they will be written by the calling routine.

Specified by:
write in class PDFObject
Parameters:
os - OutputStream to send the object to
Throws:
java.io.IOException - on error

getIndex

protected int getIndex(PDFOutline outline)
This is called by children to find their position in this outlines tree.

Parameters:
outline - PDFOutline to search for
Returns:
index within Vector

getLast

protected int getLast()
Returns the last index in this outline

Returns:
last index in outline

getNode

protected PDFOutline getNode(int i)
Returns the outline at a specified position.

Parameters:
i - index
Returns:
the node at index i

elements

public java.util.Enumeration elements()
Returns all outlines directly below this one.

Returns:
Enumeration of child elements

descendants

protected int descendants()
Returns the total number of descendants below this one.

Returns:
the number of descendants below this one