|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.icesoft.pdf.pobjects.Document
The Document class represents a PDF document and provides
access to the hierarchy of objects contained in the body section of the
PDF document. Most of the objects in the hierarchy are dictionaries which
contain references to page content and other objects such such as annotations.
For more information on the document object hierarchy, see the ICEpdf
Developer's Guide.
The Document class also provides access to methods responsible
for rendering PDF document content. Methods are available to capture page
content to a graphics context or extract image and text data on a page-by-page
basis.
If your PDF rendering application will be accessing encrypted documents, it is important to implement the SecurityCallback. This interface provides methods for getting password data from a user if needed.
| Constructor Summary | |
Document()
Creates a new instance of a Document. |
|
| Method Summary | |
void |
dispose()
Dispose of Document, freeing up all used resources. |
Catalog |
getCatalog()
Gets the Document's Catalog as specified by the Document hierarchy. |
String |
getDocumentLocation()
Returns the file location or URL of this Document. |
String |
getDocumentOrigin()
Returns the origin (filepath or URL) of this Document. |
PInfo |
getInfo()
Gets the document's information as specified in the PTrailer in the document hierarchy. |
static String |
getLibraryVersion()
Gets the version number of ICEpdf rendering core. |
int |
getNumberOfPages()
Returns the total number of pages in this document. |
PDimension |
getPageDimension(int pageNumber,
float userRotation)
Gets the page dimension of the indicated page number using the specified rotation factor. |
PDimension |
getPageDimension(int pageNumber,
float userRotation,
float userZoom)
Gets the page dimension of the indicated page number using the specified rotation and zoom settings. |
Image |
getPageImage(int pageNumber,
int renderHintType,
int pageBoundary,
float userRotation,
float userZoom)
Gets an Image of the specified page. |
Vector |
getPageImages(int pageNumber)
Gets a vector of Images where each index represents an image inside the specified page. |
Vector |
getPageText(int pageNumber)
Gets a vector of StringBuffers where each index represents a text block inside the specified page number. |
PageTree |
getPageTree()
Gets the Document Catalog's PageTree entry as specified by the Document hierarchy. |
SecurityManager |
getSecurityManager()
Gets the security manager for this document. |
void |
paintPage(int pageNumber,
Graphics g,
int renderHintType,
int pageBoundary,
float userRotation,
float userZoom)
Paints the contents of the given page number to the graphics context using the specified rotation, zoom, rendering hints and page boundary. |
void |
setByteArray(byte[] data,
int offset,
int length,
String pathOrURL)
Load a PDF file from the given byte array and initiates the document's Catalog. |
void |
setFile(String filepath)
Load a PDF file from the given path and initiates the document's Catalog. |
void |
setInputStream(InputStream in,
String pathOrURL)
Load a PDF file from the given input stream and initiates the document's Catalog. |
void |
setSecurityCallback(SecurityCallback securityCallback)
Sets the security callback to be used for this document. |
void |
setUrl(URL url)
Load a PDF file from the given URL and initiates the document's Catalog. |
void |
writeToOutputStream(OutputStream out)
Takes the internal PDF data, which may be in a file or in RAM, and write it to the provided OutputStream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Document()
| Method Detail |
public static String getLibraryVersion()
public void setFile(String filepath)
throws PDFException,
PDFSecurityException,
FileNotFoundException,
IOException
filepath - path of PDF document.
PDFException - if an invalid file encoding.
PDFSecurityException - if a security provider cannot be found
or there is an error decrypting the file.
FileNotFoundException - if an invalid filepath.
IOException - if a problem setting up, or parsing the file.
public void setUrl(URL url)
throws PDFException,
PDFSecurityException,
IOException
url - location of file.
PDFException - an invalid file encoding.
PDFSecurityException - if a security provider can not be found
or there is an error decrypting the file.
IOException - if a problem downloading, setting up, or parsing the file.
public void setInputStream(InputStream in,
String pathOrURL)
throws PDFException,
PDFSecurityException,
IOException
in - input stream containing PDF datapathOrURL - value assigned to document origin
PDFException - an invalid stream or file encoding
PDFSecurityException - if a security provider can not be found
or there is an error decrypting the file.
IOException - if a problem setting up, or parsing the SeekableInput.
public void setByteArray(byte[] data,
int offset,
int length,
String pathOrURL)
throws PDFException,
PDFSecurityException,
IOException
data - byte array containing PDF dataoffset - the index into the byte array where the PDF data beginslength - the number of bytes in the byte array belonging to the PDF datapathOrURL - value assigned to document origin
PDFException - an invalid stream or file encoding
PDFSecurityException - if a security provider can not be found
or there is an error decrypting the file.
IOException - if a problem setting up, or parsing the SeekableInput.
public PDimension getPageDimension(int pageNumber,
float userRotation)
pageNumber - Page number for the given dimension. The page
number is zero-based.userRotation - Rotation, in degrees, that has been applied to page
when calculating the dimension.
getPageDimension(int, float, float)
public PDimension getPageDimension(int pageNumber,
float userRotation,
float userZoom)
pageNumber - Page number for the given dimension. The page
number is zero-based.userRotation - Rotation, in degrees, that has been applied to page
when calculating the dimension.userZoom - Any deviation from the page's actual size, by zooming in or out.
getPageDimension(int, float)public String getDocumentOrigin()
getDocumentLocation()public String getDocumentLocation()
getDocumentOrigin()public int getNumberOfPages()
public void paintPage(int pageNumber,
Graphics g,
int renderHintType,
int pageBoundary,
float userRotation,
float userZoom)
pageNumber - Page number to paint. The page number is zero-based.g - graphics context to which the page content will be painted.renderHintType - Constant specified by the GraphicsRenderingHints class.
There are two possible entries, SCREEN and PRINT, each with configurable
rendering hints settings.pageBoundary - Constant specifying the page boundary to use when
painting the page content.userRotation - Rotation factor, in degrees, to be applied to the rendered page.userZoom - Zoom factor to be applied to the rendered page.public void dispose()
public void writeToOutputStream(OutputStream out)
throws IOException
out - OutputStream to which the PDF file bytes are written.
IOException - if there is some problem reading or writing the PDF data
public Image getPageImage(int pageNumber,
int renderHintType,
int pageBoundary,
float userRotation,
float userZoom)
pageNumber - Page number of the page to capture the image rendering.
The page number is zero-based.renderHintType - Constant specified by the GraphicsRenderingHints class.
There are two possible entries, SCREEN and PRINT each with configurable
rendering hints settings.pageBoundary - Constant specifying the page boundary to use when
painting the page content. Typically use Page.BOUNDARY_CROPBOX.userRotation - Rotation factor, in degrees, to be applied to the rendered page.
Arbitrary rotations are not currently supported for this method,
so only the following values are valid: 0.0f, 90.0f, 180.0f, 270.0f.userZoom - Zoom factor to be applied to the rendered page.
public Vector getPageText(int pageNumber)
pageNumber - Page number of page in which text extraction will act on.
The page number is zero-based.
public SecurityManager getSecurityManager()
public void setSecurityCallback(SecurityCallback securityCallback)
securityCallback - a class which implements the SecurityCallback
interface.public PInfo getInfo()
for more information.public Vector getPageImages(int pageNumber)
pageNumber - page number to act on. Zero-based page number.
public PageTree getPageTree()
public Catalog getCatalog()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||