org.pdfbox.pdmodel.encryption
Class AccessPermission
java.lang.Object
org.pdfbox.pdmodel.encryption.AccessPermission
public class AccessPermission
extends java.lang.Object
This class represents the access permissions to a document.
These permissions are specified in the PDF format specifications, they include:
- print the document
- modify the content of the document
- copy or extract content of the document
- add or modify annotations
- fill in interactive form fields
- extract text and graphics for accessibility to visually impaired people
- assemble the document
- print in degraded quality
This class can be used to protect a document by assigning access permissions to recipients.
In this case, it must be used with a specific ProtectionPolicy.
When a document is decrypted, it has a currentAccessPermission property which is the access permissions
granted to the user who decrypted the document.
boolean | canAssembleDocument() - This will tell if the user can insert/rotate/delete pages.
|
boolean | canExtractContent() - This will tell if the user can extract text and images from the PDF document.
|
boolean | canExtractForAccessibility() - This will tell if the user can extract text and images from the PDF document
for accessibility purposes.
|
boolean | canFillInForm() - This will tell if the user can fill in interactive forms.
|
boolean | canModify() - This will tell if the user can modify contents of the document.
|
boolean | canModifyAnnotations() - This will tell if the user can add/modify text annotations, fill in interactive forms fields.
|
boolean | canPrint() - This will tell if the user can print.
|
boolean | canPrintDegraded() - This will tell if the user can print the document in a degraded format.
|
static AccessPermission | getOwnerAccessPermission() - returns an access permission object for a document owner.
|
int | getPermissionBytes() - The returns an integer representing the access permissions.
|
int | getPermissionBytesForPublicKey() - This returns an integer representing the access permissions.
|
boolean | isOwnerPermission() - This will tell if the access permission corresponds to owner
access permission (no restriction).
|
boolean | isReadOnly() - This will tell if the object has been set as read only.
|
void | setCanAssembleDocument(boolean allowAssembly) - Set if the user can insert/rotate/delete pages.
|
void | setCanExtractContent(boolean allowExtraction) - Set if the user can extract content from the document.
|
void | setCanExtractForAccessibility(boolean allowExtraction) - Set if the user can extract content from the document for accessibility purposes.
|
void | setCanFillInForm(boolean allowFillingInForm) - Set if the user can fill in interactive forms.
|
void | setCanModify(boolean allowModifications) - Set if the user can modify the document.
|
void | setCanModifyAnnotations(boolean allowAnnotationModification) - Set if the user can modify annotations.
|
void | setCanPrint(boolean allowPrinting) - Set if the user can print.
|
void | setCanPrintDegraded(boolean allowAssembly) - Set if the user can print the document in a degraded format.
|
void | setReadOnly() - Locks the access permission read only (ie, the setters will have no effects).
|
AccessPermission
public AccessPermission()
Create a new access permission object.
By default, all permissions are granted.
AccessPermission
public AccessPermission(byte[] b)
Create a new access permission object from a byte array.
Bytes are ordered most significant byte first.
b
- the bytes as defined in PDF specs
canAssembleDocument
public boolean canAssembleDocument()
This will tell if the user can insert/rotate/delete pages.
- true If supplied with the user password they are allowed to extract content
from the PDF document
canExtractContent
public boolean canExtractContent()
This will tell if the user can extract text and images from the PDF document.
- true If supplied with the user password they are allowed to extract content
from the PDF document
canExtractForAccessibility
public boolean canExtractForAccessibility()
This will tell if the user can extract text and images from the PDF document
for accessibility purposes.
- true If supplied with the user password they are allowed to extract content
from the PDF document
canFillInForm
public boolean canFillInForm()
This will tell if the user can fill in interactive forms.
- true If supplied with the user password they are allowed to fill in form fields.
canModify
public boolean canModify()
This will tell if the user can modify contents of the document.
- true If supplied with the user password they are allowed to modify the document
canModifyAnnotations
public boolean canModifyAnnotations()
This will tell if the user can add/modify text annotations, fill in interactive forms fields.
- true If supplied with the user password they are allowed to modify annotations.
canPrint
public boolean canPrint()
This will tell if the user can print.
- true If supplied with the user password they are allowed to print.
canPrintDegraded
public boolean canPrintDegraded()
This will tell if the user can print the document in a degraded format.
- true If supplied with the user password they are allowed to print the
document in a degraded format.
getOwnerAccessPermission
public static AccessPermission getOwnerAccessPermission()
returns an access permission object for a document owner.
- A standard owner access permission set.
getPermissionBytes
public int getPermissionBytes()
The returns an integer representing the access permissions.
This integer can be used for standard PDF encryption as specified
in the PDF specifications.
- the integer representing the access permissions
getPermissionBytesForPublicKey
public int getPermissionBytesForPublicKey()
This returns an integer representing the access permissions.
This integer can be used for public key encryption. This format
is not documented in the PDF specifications but is necessary for compatibility
with Adobe Acrobat and Adobe Reader.
- the integer representing access permissions
isOwnerPermission
public boolean isOwnerPermission()
This will tell if the access permission corresponds to owner
access permission (no restriction).
- true if the access permission does not restrict the use of the document
isReadOnly
public boolean isReadOnly()
This will tell if the object has been set as read only.
- true if the object is in read only mode.
setCanAssembleDocument
public void setCanAssembleDocument(boolean allowAssembly)
Set if the user can insert/rotate/delete pages.
This method will have no effect if the object is in read only mode
allowAssembly
- A boolean determining if the user can assemble the document.
setCanExtractContent
public void setCanExtractContent(boolean allowExtraction)
Set if the user can extract content from the document.
This method will have no effect if the object is in read only mode
allowExtraction
- A boolean determining if the user can extract content
from the document.
setCanExtractForAccessibility
public void setCanExtractForAccessibility(boolean allowExtraction)
Set if the user can extract content from the document for accessibility purposes.
This method will have no effect if the object is in read only mode
allowExtraction
- A boolean determining if the user can extract content
from the document.
setCanFillInForm
public void setCanFillInForm(boolean allowFillingInForm)
Set if the user can fill in interactive forms.
This method will have no effect if the object is in read only mode
allowFillingInForm
- A boolean determining if the user can fill in interactive forms.
setCanModify
public void setCanModify(boolean allowModifications)
Set if the user can modify the document.
This method will have no effect if the object is in read only mode
allowModifications
- A boolean determining if the user can modify the document.
setCanModifyAnnotations
public void setCanModifyAnnotations(boolean allowAnnotationModification)
Set if the user can modify annotations.
This method will have no effect if the object is in read only mode
allowAnnotationModification
- A boolean determining if the user can modify annotations.
setCanPrint
public void setCanPrint(boolean allowPrinting)
Set if the user can print.
This method will have no effect if the object is in read only mode
allowPrinting
- A boolean determining if the user can print.
setCanPrintDegraded
public void setCanPrintDegraded(boolean allowAssembly)
Set if the user can print the document in a degraded format.
This method will have no effect if the object is in read only mode
allowAssembly
- A boolean determining if the user can print the
document in a degraded format.
setReadOnly
public void setReadOnly()
Locks the access permission read only (ie, the setters will have no effects).
After that, the object cannot be unlocked.
This method is used for the currentAccessPermssion of a document to avoid
users to change access permission.