com.qoppa.pdf
Class PDFPermissions

java.lang.Object
  extended bycom.qoppa.pdf.PDFPermissions

public class PDFPermissions
extends Object

This class contains information regarding a PDF document permissions. The list of permissions are the following: assemble the document, change the document, extract text and graphics, extract content for accessibility, fill form fields, modify annotations, print, print high resolution.

Author:
Qoppa Software

Constructor Summary
PDFPermissions()
          Creates a new PDFPermissions object with all permissions granted.
PDFPermissions(boolean allperms)
          Creates a new PDFPermissions object with all permissions set to allperms.
PDFPermissions(int perms, boolean ownerPasswordEntered)
          Creates a new PDFPermissions object using perms, the permissions integer representing the 12 permissions bits as specified in the PDF documentation.
 
Method Summary
 int getPermFlag()
          Returns the permissions int representing the 12 permissions bits as specified in the PDF documentation.
 boolean hasAllPermissions()
          Returns true if all permissions are granted for the document.
 boolean isAssembleDocumentAllowed()
          Returns the permission to assemble the document: - insert, rotate or delete pages - create bookmarks - create thumbnail images This permission is automatically granted if the permission to change the document is granted (@see PDFPermissions#isChangeDocumentAllowed()).
 boolean isChangeDocumentAllowed()
          Returns the permission to change the document.
 boolean isExtractTextGraphicsAllowed()
          Returns the permission to extract text and graphics.
 boolean isExtractTextGraphicsForAccessibilityAllowed()
          Returns the permission to extract text and graphics in support of accessibility to disabled users or other purposes.
 boolean isFillFormFieldsAllowed()
          Returns the permission to fill form fields and sign the document.
 boolean isModifyAnnotsAllowed()
          Returns the permission to add or modify text annotations in the document.
 boolean isPrintAllowed()
          Returns the permission to print the document.
 boolean isPrintHighResAllowed()
          Returns the permission to print the document at high resolution.
 boolean ownerPasswordEntered()
          Return a flag indicating whether the document was opened using the owner password if the document is encrypted.
 void setAssembleDocumentAllowed(boolean allowed)
          Sets the permission to assemble the document.
 void setChangeDocumentAllowed(boolean allowed)
          Sets the permission to change the document.
 void setExtractTextGraphicsAllowed(boolean allowed)
          Sets the permission to extract text and graphics.
 void setExtractTextGraphicsForAccessibilityAllowed(boolean allowed)
          Sets the permission to extract text and graphics in support of accessibility to disabled users or other purposes.
 void setFillFormFieldsAllowed(boolean allowed)
          Sets the permission to fill form fields and sign the document.
 void setModifyAnnotsAllowed(boolean allowed)
          Sets the permission to add or modify annotations in the document.
 void setPermFlag(int perms)
          Sets the permissions from the int representing the 12 permissions bits as specified in the PDF documentation.
 void setPrintAllowed(boolean allowed)
          Sets the permission to print the document.
 void setPrintHighResAllowed(boolean allowed)
          Sets the permission to print the document at high resolution.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFPermissions

public PDFPermissions()
Creates a new PDFPermissions object with all permissions granted.


PDFPermissions

public PDFPermissions(boolean allperms)
Creates a new PDFPermissions object with all permissions set to allperms.

Parameters:
allperms - flag for all permissions

PDFPermissions

public PDFPermissions(int perms,
                      boolean ownerPasswordEntered)
Creates a new PDFPermissions object using perms, the permissions integer representing the 12 permissions bits as specified in the PDF documentation.

Parameters:
perms - the permissions integer representing the 12 permissions bits as specified in the PDF documentation.
ownerPasswordEntered - flag indicating wether the owner password was entered when opening the document
Method Detail

getPermFlag

public int getPermFlag()
Returns the permissions int representing the 12 permissions bits as specified in the PDF documentation.


hasAllPermissions

public boolean hasAllPermissions()
Returns true if all permissions are granted for the document.

Returns:
true if all permissions are granted.

isAssembleDocumentAllowed

public boolean isAssembleDocumentAllowed()
Returns the permission to assemble the document: - insert, rotate or delete pages - create bookmarks - create thumbnail images This permission is automatically granted if the permission to change the document is granted (@see PDFPermissions#isChangeDocumentAllowed()).

Returns:
Permission to assemble the document.

isChangeDocumentAllowed

public boolean isChangeDocumentAllowed()
Returns the permission to change the document. When this permission is granted, the 3 following permissions are also granted: Assemble document @see PDFPermissions#isAssembleDocumentAllowed() Modify Annotations @see PDFPermissions#isModifyAnnotsAllowed() Fill Form Fields @see PDFPermissions#isFillFormFieldsAllowed()

Returns:
Permission to change the document.

isExtractTextGraphicsAllowed

public boolean isExtractTextGraphicsAllowed()
Returns the permission to extract text and graphics. When this permission is granted, the permission to extract for accessibility is automatically granted (@see PDFPermissions#isExtractTextGraphicsForAccessibilityAllowed()). When this permission is not granted, the permission to extract for accessibility can be set independently.

Returns:
Permission to extract text and graphics.

isExtractTextGraphicsForAccessibilityAllowed

public boolean isExtractTextGraphicsForAccessibilityAllowed()
Returns the permission to extract text and graphics in support of accessibility to disabled users or other purposes. This permission is automatically granted when the permission to extract text and graphics is granted (@see PDFPermissions#isExtractTextGraphicsAllowed()).

Returns:
Permission to extract text and graphics for accessibility.

isFillFormFieldsAllowed

public boolean isFillFormFieldsAllowed()
Returns the permission to fill form fields and sign the document. This permission is automatically granted if the modify annotations permissions is granted (@see PDFPermissions#isModifyAnnotsAllowed()) or if the permission to change the document is granted (@see PDFPermissions#isChangeDocumentAllowed()). When this permission is granted and the permission to change document is also granted, create or modify interactive form fields (including signature fields) is allowed.");

Returns:
Permission to fill form fields.

isModifyAnnotsAllowed

public boolean isModifyAnnotsAllowed()
Returns the permission to add or modify text annotations in the document. When this permission is granted, the permission to fill form fields is automatically granted (@see PDFPermissions#isFillFormFieldsAllowed()). When this permission is not granted, then the permission to fill form fields can be granted independently. When this permission is granted and the permission to change document is also granted (@see PDFPermissions#isChangeDocumentAllowed()), create or modify interactive form fields (including signature fields) is allowed."); This permission is automatically granted if the permission to change the document is granted (@see PDFPermissions#isChangeDocumentAllowed()).

Returns:
Permission to add or modify text annotations.

isPrintAllowed

public boolean isPrintAllowed()
Returns the permission to print the document. This permission is automatically granted if the permission to print the document at high resolution is granted (@see PDFPermissions#isPrintHighResAllowed())

Returns:
Permission to print the document.

isPrintHighResAllowed

public boolean isPrintHighResAllowed()
Returns the permission to print the document at high resolution. When this permission is granted, the permission to print the document is automatically granted (@see PDFPermissions#isPrintAllowed()). When this permission is not granted, then the permission to print the document can be granted independently.

Returns:
Permission to print the document at high resolution.

ownerPasswordEntered

public boolean ownerPasswordEntered()
Return a flag indicating whether the document was opened using the owner password if the document is encrypted. This flag is useful when enforcing permissions, if the document was opened with the owner password then application should allow any operations on the PDF document. If the document is not encrypted, this flag will return true


setAssembleDocumentAllowed

public void setAssembleDocumentAllowed(boolean allowed)
Sets the permission to assemble the document. Assembling the document can be done by: - inserting, rotating or deleting pages - creating bookmarks - creating thumbnail images

Parameters:
allowed - the permission to assemble the document.
See Also:
setChangeDocumentAllowed(boolean)

setChangeDocumentAllowed

public void setChangeDocumentAllowed(boolean allowed)
Sets the permission to change the document. When this permission is granted, the 3 permissions: Assemble Document (@see PDFPermissions#setAssembleDocumentAllowed(boolean)) Modify Annotations (@see PDFPermissions#setModifyAnnotsAllowed(boolean)) Fill Form Fields (@see PDFPermissions#setFillFormFieldsAllowed(boolean)) are also automatically granted. When this permission is not granted, the 3 permissions mentioned above can independently be granted.

Parameters:
allowed - the permission to change the document

setExtractTextGraphicsAllowed

public void setExtractTextGraphicsAllowed(boolean allowed)
Sets the permission to extract text and graphics. When this permission is granted, the permission to extract for accessibility is automatically granted (@see PDFPermissions#isExtractTextGraphicsForAccessibilityAllowed()). When this permission is not granted, the permission to extract for accessibility can be set independently.

Parameters:
allowed - the permission to extract text and graphics.

setExtractTextGraphicsForAccessibilityAllowed

public void setExtractTextGraphicsForAccessibilityAllowed(boolean allowed)
Sets the permission to extract text and graphics in support of accessibility to disabled users or other purposes.

Parameters:
allowed - the permission to extract text and graphics.
See Also:
isExtractTextGraphicsAllowed()

setFillFormFieldsAllowed

public void setFillFormFieldsAllowed(boolean allowed)
Sets the permission to fill form fields and sign the document.

Parameters:
allowed - the permission to fill form fields.
See Also:
setChangeDocumentAllowed(boolean)

setModifyAnnotsAllowed

public void setModifyAnnotsAllowed(boolean allowed)
Sets the permission to add or modify annotations in the document. When this permission is granted, the permission to fill form fields is automatically granted (@see PDFPermissions#setFillFormFieldsAllowed(boolean fillFormsAllowed)). When this permission is not granted, then the permission to fill form fields can be granted independently. When this permission is granted and the permission to change document is also granted (@see PDFPermissions#setChangeDocumentAllowed(boolean)), create or modify interactive form fields (including signature fields) is allowed.");

Parameters:
allowed - the permission to add or modify annotations.

setPermFlag

public void setPermFlag(int perms)
Sets the permissions from the int representing the 12 permissions bits as specified in the PDF documentation.

Parameters:
perms - the permissions int.

setPrintAllowed

public void setPrintAllowed(boolean allowed)
Sets the permission to print the document.

Parameters:
allowed - to print the document.
See Also:
setPrintHighResAllowed(boolean)

setPrintHighResAllowed

public void setPrintHighResAllowed(boolean allowed)
Sets the permission to print the document at high resolution. When this permission is granted, the Print permission is also automatically granted (@see PDFPermissions#isPrintAllowed()) When this permission is not granted, the Print permission can be granted independently.

Parameters:
allowed - the permission to print at high resolution