public class PDFFile
extends java.lang.Object
Constructor and Description |
---|
PDFFile(java.nio.ByteBuffer buf)
get a PDFFile from a .pdf file.
|
PDFFile(java.nio.ByteBuffer buf,
PDFPassword password)
get a PDFFile from a .pdf file.
|
Modifier and Type | Method and Description |
---|---|
PDFObject |
dereference(PDFXref ref,
PDFDecrypter decrypter)
Used internally to track down PDFObject references.
|
PDFDecrypter |
getDefaultDecrypter()
Get the default decrypter for the document
|
int |
getMajorVersion()
return the major version of the PDF header.
|
java.util.Iterator<java.lang.String> |
getMetadataKeys()
Get the keys into the Info metadata, for use with
getStringMetadata(String) |
int |
getMinorVersion()
return the minor version of the PDF header.
|
int |
getNumPages()
return the number of pages in this PDFFile.
|
OutlineNode |
getOutline()
Gets the outline tree as a tree of OutlineNode, which is a subclass
of DefaultMutableTreeNode.
|
PDFPage |
getPage(int pagenum)
Get the page commands for a given page in a separate thread.
|
PDFPage |
getPage(int pagenum,
boolean wait)
Get the page commands for a given page.
|
int |
getPageNumber(PDFObject page)
Gets the page number (starting from 1) of the page represented by
a particular PDFObject.
|
PDFObject |
getRoot()
get the root PDFObject of this PDFFile.
|
java.lang.String |
getStringMetadata(java.lang.String name)
Get metadata (e.g., Author, Title, Creator) from the Info dictionary
as a string.
|
java.lang.String |
getVersionString()
return the version string from the PDF header.
|
static boolean |
isDelimiter(int c)
Is the argument a delimiter according to the PDF spec?
|
boolean |
isPrintable()
Gets whether the owner of the file has given permission to print
the file.
|
static boolean |
isRegularCharacter(int c)
return true if the character is neither a whitespace or a delimiter.
|
boolean |
isSaveable()
Gets whether the owner of the file has given permission to save
a copy of the file.
|
static boolean |
isWhiteSpace(int c)
Is the argument a white space character according to the PDF spec?.
|
static java.awt.geom.Rectangle2D |
parseNormalisedRectangle(PDFObject obj) |
void |
stop(int pageNum)
Stop the rendering of a particular image on this page
|
public static final int NUL_CHAR
public static final int FF_CHAR
public PDFFile(java.nio.ByteBuffer buf) throws java.io.IOException
Use the getPage(...) methods to get a page from the PDF file.
buf
- the RandomAccessFile containing the PDF.java.io.IOException
- if there's a problem reading from the bufferPDFParseException
- if the document appears to be malformed, or
its features are unsupported. If the file is encrypted in a manner that
the product or platform does not support then the exception's cause
will be an instance of UnsupportedEncryptionException
.PDFAuthenticationFailureException
- if the file is password
protected and requires a passwordpublic PDFFile(java.nio.ByteBuffer buf, PDFPassword password) throws java.io.IOException
Use the getPage(...) methods to get a page from the PDF file.
buf
- the RandomAccessFile containing the PDF.password
- the user or owner passwordjava.io.IOException
- if there's a problem reading from the bufferPDFParseException
- if the document appears to be malformed, or
its features are unsupported. If the file is encrypted in a manner that
the product or platform does not support then the exception's cause
will be an instance of UnsupportedEncryptionException
.PDFAuthenticationFailureException
- if the file is password
protected and the supplied password does not decrypt the documentpublic boolean isPrintable()
public boolean isSaveable()
public PDFObject getRoot()
public int getNumPages()
public java.lang.String getStringMetadata(java.lang.String name) throws java.io.IOException
name
- the name of the metadata key (e.g., Author)java.io.IOException
- if the metadata cannot be readpublic java.util.Iterator<java.lang.String> getMetadataKeys() throws java.io.IOException
getStringMetadata(String)
java.io.IOException
- if the keys cannot be readpublic PDFObject dereference(PDFXref ref, PDFDecrypter decrypter) throws java.io.IOException
Since this is the only public method for tracking down PDF objects, it is synchronized. This means that the PDFFile can only hunt down one object at a time, preventing the file's location from getting messed around.
This call stores the current buffer position before any changes are made and restores it afterwards, so callers need not know that the position has changed.
java.io.IOException
public static boolean isWhiteSpace(int c)
public static boolean isDelimiter(int c)
ISO 32000-1:2008 - Table 2
c
- the character to testpublic static boolean isRegularCharacter(int c)
c
- the character to testpublic int getMajorVersion()
public int getMinorVersion()
public java.lang.String getVersionString()
public OutlineNode getOutline() throws java.io.IOException
java.io.IOException
public int getPageNumber(PDFObject page) throws java.io.IOException
java.io.IOException
public PDFPage getPage(int pagenum)
pagenum
- the number of the page to get commands forpublic PDFPage getPage(int pagenum, boolean wait)
pagenum
- the number of the page to get commands forwait
- if true, do not exit until the page is complete.public void stop(int pageNum)
public static java.awt.geom.Rectangle2D parseNormalisedRectangle(PDFObject obj) throws java.io.IOException
java.io.IOException
public PDFDecrypter getDefaultDecrypter()