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
protected  boolean isRotationFactor
          Indicates that the PageTree has a rotation factor which should be respected.
protected  float rotationFactor
          Inheritable rotation factor by child pages.
 
Fields inherited from class org.icepdf.core.pobjects.Dictionary
entries, isDeleted, isNew, library, SUBTYPE_KEY, TYPE_KEY
 
Constructor Summary
PageTree(Library l, java.util.Hashtable h)
          Creates a new instance of a PageTree.
 
Method Summary
protected  void dispose(boolean cache)
          Dispose the PageTree.
 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, java.lang.Object user)
          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 releasePage(int pageNumber, java.lang.Object user)
          Release the Page that was locked by getPage for user.
 void releasePage(Page page, java.lang.Object user)
          Release the Page that was locked by getPage for user.
 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, 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

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.Hashtable h)
Creates a new instance of a PageTree.

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

dispose

protected void dispose(boolean cache)
Dispose the PageTree.


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,
                    java.lang.Object user)
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.
user - The object that is asking for the Page to be locked on its behalf.
Returns:
The requested Page.
See Also:
releasePage(org.icepdf.core.pobjects.Page, java.lang.Object)

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.

releasePage

public void releasePage(Page page,
                        java.lang.Object user)
Release the Page that was locked by getPage for user.

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:
page - The Page that was locked
user - The entity for whom the page was locked.
See Also:
getPage(int, java.lang.Object)

releasePage

public void releasePage(int pageNumber,
                        java.lang.Object user)
Release the Page that was locked by getPage for user.

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 - The page number of the Page that was locked.
user - The entity for whom the page was locked.
See Also:
getPage(int, java.lang.Object)

toString

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

Overrides:
toString in class Dictionary
Returns:
dictionary values.