|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pdfbox.pdmodel.PDDocument
This is the in-memory representation of the PDF document. You need to call close() on this object when you are done using it!!
Constructor Summary | |
PDDocument()
Constructor, creates a new PDF Document with no pages. |
|
PDDocument(COSDocument doc)
Constructor that uses an existing document. |
Method Summary | |
void |
addPage(PDPage page)
This will add a page to the document. |
void |
close()
This will close the underlying COSDocument object. |
void |
decrypt(String password)
This will decrypt a document. |
void |
encrypt(String ownerPassword,
String userPassword)
This will encrypt a document. |
COSDocument |
getDocument()
This will get the low level document. |
PDDocumentCatalog |
getDocumentCatalog()
This will get the document CATALOG. |
PDDocumentInformation |
getDocumentInformation()
This will get the document info dictionary. |
PDEncryptionDictionary |
getEncryptionDictionary()
This will get the encryption dictionary for this document. |
int |
getPageCount()
This will return the total page count of the PDF document. |
PDPage |
importPage(PDPage page)
This will import and copy the contents from another location. |
boolean |
isEncrypted()
This will tell if this document is encrypted or not. |
boolean |
isOwnerPassword(String password)
This will determine if this is the owner password. |
boolean |
isUserPassword(String password)
This will determine if this is the user password. |
static PDDocument |
load(File file)
This will load a document from a file. |
static PDDocument |
load(InputStream input)
This will load a document from an input stream. |
static PDDocument |
load(String filename)
This will load a document from a file. |
void |
save(OutputStream output)
This will save the document to an output stream. |
void |
save(String fileName)
This will save this document to the filesystem. |
void |
setDocumentInformation(PDDocumentInformation info)
This will set the document information for this document. |
void |
setEncryptionDictionary(PDEncryptionDictionary encDictionary)
This will set the encryption dictionary for this document. |
boolean |
wasDecryptedWithOwnerPassword()
This will tell if the document was decrypted with the master password. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PDDocument() throws IOException
IOException
- If there is an error creating this document.public PDDocument(COSDocument doc)
doc
- The COSDocument that this document wraps.Method Detail |
public void addPage(PDPage page)
page
- The page to add to the document.public PDPage importPage(PDPage page) throws IOException
page
- The page to import.
IOException
- If there is an error copying the page.public COSDocument getDocument()
public PDDocumentInformation getDocumentInformation()
public void setDocumentInformation(PDDocumentInformation info)
info
- The updated document information.public PDDocumentCatalog getDocumentCatalog()
public boolean isEncrypted()
public PDEncryptionDictionary getEncryptionDictionary() throws IOException
IOException
- If there is an error determining which security handler to use.public void setEncryptionDictionary(PDEncryptionDictionary encDictionary) throws IOException
encDictionary
- The encryption dictionary(most likely a PDStandardEncryption object)
IOException
- If there is an error determining which security handler to use.public boolean isUserPassword(String password) throws IOException, CryptographyException
password
- The plain text user password.
IOException
- If there is an error determining if it is the user password.
CryptographyException
- If there is an error in the encryption algorithms.public boolean isOwnerPassword(String password) throws IOException, CryptographyException
password
- The plain text owner password.
IOException
- If there is an error determining if it is the user password.
CryptographyException
- If there is an error in the encryption algorithms.public void decrypt(String password) throws CryptographyException, IOException, InvalidPasswordException
password
- Either the user or owner password.
CryptographyException
- If there is an error decrypting the document.
IOException
- If there is an error getting the stream data.
InvalidPasswordException
- If the password is not a user or owner password.public boolean wasDecryptedWithOwnerPassword()
public void encrypt(String ownerPassword, String userPassword) throws CryptographyException, IOException
ownerPassword
- The owner password to encrypt the document.userPassword
- The user password to encrypt the document.
CryptographyException
- If an error occurs during encryption.
IOException
- If there is an error accessing the data.public static PDDocument load(String filename) throws IOException
filename
- The name of the file to load.
IOException
- If there is an error reading from the stream.public static PDDocument load(File file) throws IOException
file
- The name of the file to load.
IOException
- If there is an error reading from the stream.public static PDDocument load(InputStream input) throws IOException
input
- The stream that contains the document.
IOException
- If there is an error reading from the stream.public void save(String fileName) throws IOException, COSVisitorException
fileName
- The file to save as.
IOException
- If there is an error saving the document.
COSVisitorException
- If an error occurs while generating the data.public void save(OutputStream output) throws IOException, COSVisitorException
output
- The stream to write to.
IOException
- If there is an error writing the document.
COSVisitorException
- If an error occurs while generating the data.public int getPageCount() throws IOException
IOException
- If there is an error getting the page countpublic void close() throws IOException
IOException
- If there is an error releasing resources.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |