org.pdfbox.encryption
Class DocumentEncryption

java.lang.Object
  extended byorg.pdfbox.encryption.DocumentEncryption

public class DocumentEncryption
extends Object

This class will deal with encrypting/decrypting a document.

Version:
$Revision: 1.8 $
Author:
Ben Litchfield

Constructor Summary
DocumentEncryption(COSDocument doc)
          Constructor.
DocumentEncryption(PDDocument doc)
          Constructor.
 
Method Summary
 void decryptDocument(String password)
          This will decrypt the document.
 void encryptDocument(String ownerPassword, String userPassword)
          This will encrypt the given document, given the owner password and user password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentEncryption

public DocumentEncryption(PDDocument doc)
Constructor.

Parameters:
doc - The document to decrypt.

DocumentEncryption

public DocumentEncryption(COSDocument doc)
Constructor.

Parameters:
doc - The document to decrypt.
Method Detail

encryptDocument

public void encryptDocument(String ownerPassword,
                            String userPassword)
                     throws CryptographyException,
                            IOException
This will encrypt the given document, given the owner password and user password. The encryption method used is the standard filter.

Parameters:
ownerPassword - The owner password for the encrypted pdf file.
userPassword - The user password for the encrypted pdf file.
Throws:
CryptographyException - If an error occurs during encryption.
IOException - If there is an error accessing the data.

decryptDocument

public void decryptDocument(String password)
                     throws CryptographyException,
                            IOException,
                            InvalidPasswordException
This will decrypt the document.

Parameters:
password - The password for the document.
Throws:
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.