|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.icepdf.core.pobjects.Document
public class 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 | |
|---|---|
protected long |
appendIncrementalUpdate(java.io.OutputStream out,
long documentLength)
If ICEpdf Pro, then use append an incremental update of any edits. |
void |
dispose()
Dispose of Document, freeing up all used resources. |
Catalog |
getCatalog()
Gets the Document's Catalog as specified by the Document hierarchy. |
java.lang.String |
getDocumentLocation()
Returns the file location or URL of this Document. |
java.lang.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 java.lang.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. |
java.awt.Image |
getPageImage(int pageNumber,
int renderHintType,
int pageBoundary,
float userRotation,
float userZoom)
Gets an Image of the specified page. |
java.util.Vector |
getPageImages(int pageNumber)
Gets a vector of Images where each index represents an image inside the specified page. |
PageText |
getPageText(int pageNumber)
Exposes a page's PageText object which can be used to get text with in the PDF document. |
PageTree |
getPageTree()
Gets the Document Catalog's PageTree entry as specified by the Document hierarchy. |
PageText |
getPageViewText(int pageNumber)
Exposes a page's PageText object which can be used to get text with in the PDF document. |
SecurityManager |
getSecurityManager()
Gets the security manager for this document. |
StateManager |
getStateManager()
Gets an instance of the the document state manager which stores references of object that need to be written to file. |
void |
paintPage(int pageNumber,
java.awt.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. |
long |
saveToOutputStream(java.io.OutputStream out)
Copies the pre-existing PDF file, and appends an incremental update for any edits, to the specified OutputStream. |
void |
setByteArray(byte[] data,
int offset,
int length,
java.lang.String pathOrURL)
Load a PDF file from the given byte array and initiates the document's Catalog. |
void |
setFile(java.lang.String filepath)
Load a PDF file from the given path and initiates the document's Catalog. |
void |
setInputStream(java.io.InputStream in,
java.lang.String pathOrURL)
Load a PDF file from the given input stream and initiates the document's Catalog. |
void |
setInputStream(SeekableInput in,
java.lang.String pathOrURL)
Load a PDF file from the given SeekableInput stream and initiates the document's Catalog. |
void |
setSecurityCallback(SecurityCallback securityCallback)
Sets the security callback to be used for this document. |
void |
setUrl(java.net.URL url)
Load a PDF file from the given URL and initiates the document's Catalog. |
long |
writeToOutputStream(java.io.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 java.lang.String getLibraryVersion()
public void setFile(java.lang.String filepath)
throws PDFException,
PDFSecurityException,
java.io.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.
java.io.IOException - if a problem setting up, or parsing the file.
public void setUrl(java.net.URL url)
throws PDFException,
PDFSecurityException,
java.io.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.
java.io.IOException - if a problem downloading, setting up, or parsing the file.
public void setInputStream(java.io.InputStream in,
java.lang.String pathOrURL)
throws PDFException,
PDFSecurityException,
java.io.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.
java.io.IOException - if a problem setting up, or parsing the SeekableInput.
public void setByteArray(byte[] data,
int offset,
int length,
java.lang.String pathOrURL)
throws PDFException,
PDFSecurityException,
java.io.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.
java.io.IOException - if a problem setting up, or parsing the SeekableInput.
public void setInputStream(SeekableInput in,
java.lang.String pathOrURL)
throws PDFException,
PDFSecurityException,
java.io.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.
java.io.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 java.lang.String getDocumentOrigin()
getDocumentLocation()public java.lang.String getDocumentLocation()
getDocumentOrigin()public StateManager getStateManager()
public int getNumberOfPages()
public void paintPage(int pageNumber,
java.awt.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 long writeToOutputStream(java.io.OutputStream out)
throws java.io.IOException
out - OutputStream to which the PDF file bytes are written.
java.io.IOException - if there is some problem reading or writing the PDF data
public long saveToOutputStream(java.io.OutputStream out)
throws java.io.IOException
out - OutputStream to which the PDF file bytes are written.
java.io.IOException - if there is some problem reading or writing the PDF data
protected long appendIncrementalUpdate(java.io.OutputStream out,
long documentLength)
throws java.io.IOException
out - OutputStream to which the incremental update bytes are written.documentLength - Length of the PDF file sp far, before the incremental update.
java.io.IOException
public java.awt.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 PageText getPageText(int pageNumber)
pageNumber - Page number of page in which text extraction will act on.
The page number is zero-based.
getPageViewText(int).public PageText getPageViewText(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 java.util.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 | ||||||||