Class StandardProtectionPolicy
java.lang.Object
org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy
org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy
The protection policy to add to a document for password-based protection.
The following example shows how to protect a PDF document with password.
In this example, the document will be protected so that someone opening
the document with the user password
user_pwd
will not be
able to modify the document.
AccessPermission ap = new AccessPermission(); ap.setCanModify(false); StandardProtectionPolicy policy = new StandardProtectionPolicy(owner_pwd, user_pwd, ap); doc.protect(policy);
- Author:
- Benoit Guillon
-
Constructor Summary
ConstructorsConstructorDescriptionStandardProtectionPolicy
(String ownerPassword, String userPassword, AccessPermission permissions) Creates an new instance of the standard protection policy in order to protect a PDF document with passwords. -
Method Summary
Modifier and TypeMethodDescriptionReturns the owner password.Returns the access permissionsReturns the user password.void
setOwnerPassword
(String ownerPassword) Sets the owner passwordvoid
setPermissions
(AccessPermission permissions) Sets the access permissionsvoid
setUserPassword
(String userPassword) Sets the user password.Methods inherited from class org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy
getEncryptionKeyLength, isPreferAES, setEncryptionKeyLength, setPreferAES
-
Constructor Details
-
StandardProtectionPolicy
public StandardProtectionPolicy(String ownerPassword, String userPassword, AccessPermission permissions) Creates an new instance of the standard protection policy in order to protect a PDF document with passwords.- Parameters:
ownerPassword
- The owner's password.userPassword
- The users's password.permissions
- The access permissions given to the user.
-
-
Method Details
-
getPermissions
Returns the access permissions- Returns:
- the access permissions
-
setPermissions
Sets the access permissions- Parameters:
permissions
- the new access permissions
-
getOwnerPassword
Returns the owner password.- Returns:
- the owner password
-
setOwnerPassword
Sets the owner password- Parameters:
ownerPassword
- the new owner password
-
getUserPassword
Returns the user password.- Returns:
- the user password
-
setUserPassword
Sets the user password.- Parameters:
userPassword
- the new user password
-