com.teamdev.jxdocument
Class Document

java.lang.Object
  extended by com.teamdev.jxdocument.Document

public class Document
extends java.lang.Object

Represents a PDF document. When you don't need Document instance anymore make sure that you close it using close() method, otherwise you can see memory leak.


Constructor Summary
Document(java.io.File file)
          Constructs a new Document instance from a specified PDF file.
 
Method Summary
 void close()
          Closes current document and releases all its resources and allocated memory.
 Page getPageAt(int pageIndex)
          Returns specified page in the document at specified page index/number.
 int getPageCount()
          Returns total number of pages in the PDF document.
 java.util.List<Page> getPages()
          Returns a list of pages in the PDF document.
 boolean isClosed()
          Returns true when document was closed via close() method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Document

public Document(java.io.File file)
Constructs a new Document instance from a specified PDF file.

Parameters:
file - a PDF file. The file instance must exist and represent a valid PDF file.
Throws:
java.lang.IllegalArgumentException - when file parameter is null, a directory or the file doesn't exist.
java.lang.IllegalStateException - when error occurs during document loading.
Method Detail

getPages

public java.util.List<Page> getPages()
Returns a list of pages in the PDF document.

Returns:
a list of pages in the PDF document or empty list if the document doesn't have pages.
Throws:
java.lang.IllegalStateException - when document is closed.

getPageCount

public int getPageCount()
Returns total number of pages in the PDF document.

Returns:
number of pages in the PDF document or 0 if the document has no pages.
Throws:
java.lang.IllegalStateException - when document is closed.

getPageAt

public Page getPageAt(int pageIndex)
Returns specified page in the document at specified page index/number.

Parameters:
pageIndex - represents page number in the document. Starts from 0.
Returns:
page in the PDF document.
Throws:
java.lang.IllegalArgumentException - when pageIndex is < 0 and >= total pages count.
java.lang.IllegalStateException - when document is closed.

close

public void close()
Closes current document and releases all its resources and allocated memory. When document is closed you cannot access it anymore as well as its pages, text on pages etc. To check whether document is already closed see isClosed() method.


isClosed

public boolean isClosed()
Returns true when document was closed via close() method.