org.icepdf.core.pobjects
Class PageTree

java.lang.Object
  extended by org.icepdf.core.pobjects.Dictionary
      extended by org.icepdf.core.pobjects.PageTree

public class PageTree
extends Dictionary

This class represents a document's page tree which defines the ordering of pages in the document. The tree structure allows a user to quickly open a document containing thousands of pages. The tree contains nodes of two types, page tree nodes and page nodes, where page tree nodes are intermediate nodes and pages are leaves. A simple example of this tree structure is a single page tree node that references all of the document's page objects directly.

The page tree is accessible via the document catalog and can be traversed to display a desired page or extracts its content.

Since:
2.0
See Also:
Page, Catalog

Field Summary
static Name COUNT_KEY
           
static Name CROPBOX_KEY
           
protected  boolean isRotationFactor
          Indicates that the PageTree has a rotation factor which should be respected.
static Name KIDS_KEY
           
static Name MEDIABOX_KEY
           
static Name PARENT_KEY
           
static Name RESOURCES_KEY
           
static Name ROTATE_KEY
           
protected  float rotationFactor
          Inheritable rotation factor by child pages.
static Name TYPE
           
 
Fields inherited from class org.icepdf.core.pobjects.Dictionary
entries, FORM_TYPE_KEY, isDeleted, isNew, LENGTH_KEY, library, SUBTYPE_KEY, TYPE_KEY
 
Constructor Summary
PageTree(Library l, java.util.HashMap h)
          Creates a new instance of a PageTree.
 
Method Summary
 PRectangle getCropBox()
          Gets the crop box boundary defined by this page tree.
 PRectangle getMediaBox()
          Gets the media box boundary defined by this page tree.
 int getNumberOfPages()
          In a PDF file there is a root Pages object, which contains children Page objects, as well as children PageTree objects, all arranged in a tree.
 Page getPage(int pageNumber)
          Gets a Page from the PDF file, locks it for the user, initializes the Page, and returns it.
 int getPageNumber(Reference r)
          Gets the page number of the page specifed by a reference.
 Reference getPageReference(int pageNumber)
          Get the page reference for the specified page number.
 PageTree getParent()
          Gets the page tree node that is the immediate parent of this one.
 Resources getResources()
          Gets the Resources defined by this PageTree.
 void init()
          Initiate the PageTree.
 void resetInitializedState()
          Reset the pages initialized flag and as a result subsequent calls to this PageTree may trigger a call to init().
 java.lang.String toString()
          Returns a summary of the PageTree dictionary values.
 
Methods inherited from class org.icepdf.core.pobjects.Dictionary
getEntries, getFloat, getInt, getLibrary, getNumber, getObject, getPObjectReference, isDeleted, isNew, setDeleted, setNew, setPObjectReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final Name TYPE

PARENT_KEY

public static final Name PARENT_KEY

COUNT_KEY

public static final Name COUNT_KEY

MEDIABOX_KEY

public static final Name MEDIABOX_KEY

CROPBOX_KEY

public static final Name CROPBOX_KEY

KIDS_KEY

public static final Name KIDS_KEY

ROTATE_KEY

public static final Name ROTATE_KEY

RESOURCES_KEY

public static final Name RESOURCES_KEY

rotationFactor

protected float rotationFactor
Inheritable rotation factor by child pages.


isRotationFactor

protected boolean isRotationFactor
Indicates that the PageTree has a rotation factor which should be respected.

Constructor Detail

PageTree

public PageTree(Library l,
                java.util.HashMap h)
Creates a new instance of a PageTree.

Parameters:
l - document library.
h - PageTree dictionary entries.
Method Detail

resetInitializedState

public void resetInitializedState()
Reset the pages initialized flag and as a result subsequent calls to this PageTree may trigger a call to init().


init

public void init()
Initiate the PageTree.

Overrides:
init in class Dictionary

getMediaBox

public PRectangle getMediaBox()
Gets the media box boundary defined by this page tree. The media box is a required page entry and can be inherited from its parent page tree.

Returns:
media box boundary in user space units.

getCropBox

public PRectangle getCropBox()
Gets the crop box boundary defined by this page tree. The media box is a required page entry and can be inherited from its parent page tree.

Returns:
crop box boundary in user space units.

getResources

public Resources getResources()
Gets the Resources defined by this PageTree. The Resources entry can be inherited by the child Page objects.

The caller is responsible for disposing of the returned Resources object.

Returns:
Resources associates with the PageTree

getParent

public PageTree getParent()
Gets the page tree node that is the immediate parent of this one.

Returns:
parent page tree; null, if this is the root page tree.

getPageNumber

public int getPageNumber(Reference r)
Gets the page number of the page specifed by a reference.

Parameters:
r - reference to a page in the page tree.
Returns:
page number of the specified reference. If no page is found, -1 is returned.

getNumberOfPages

public int getNumberOfPages()
In a PDF file there is a root Pages object, which contains children Page objects, as well as children PageTree objects, all arranged in a tree. getNumberOfPages() exists in every PageTree object, giving the number of Page objects under it, recursively. So, each PageTree object would have a different number of pages, and only the root PageTree objects would have a number representative of the whole Document.

Returns:
Total number of Page objects under this PageTree

getPage

public Page getPage(int pageNumber)
Gets a Page from the PDF file, locks it for the user, initializes the Page, and returns it.

ICEpdf uses a caching and memory management mechanism to reduce the CPU, I/O, and time to access a Page, which requires a locking and releasing protocol. Calls to the getPage must be matched with corresponding calls to releasePage. Calls cannot be nested, meaning that releasePage must be called before a subsequent invocation of getPage for the same pageIndex.

Parameters:
pageNumber - Zero-based index of the Page to return.
Returns:
The requested Page.

getPageReference

public Reference getPageReference(int pageNumber)
Get the page reference for the specified page number.

Parameters:
pageNumber - zero-based indox of page to find reference of.
Returns:
found page reference or null if number could not be resolved.

toString

public java.lang.String toString()
Returns a summary of the PageTree dictionary values.

Overrides:
toString in class Dictionary
Returns:
dictionary values.