PdfPermissions

Inheritance: java.lang.Object

public class PdfPermissions

Specifies the operations that are allowed to a user on an encrypted PDF document.

Examples:

Shows how to set permissions on a saved PDF document.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 builder.writeln("Hello world!");

 // Extend permissions to allow the editing of annotations.
 PdfEncryptionDetails encryptionDetails =
         new PdfEncryptionDetails("password", "", PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);

 // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
 // to modify how that method converts the document to .PDF.
 PdfSaveOptions saveOptions = new PdfSaveOptions();

 // Enable encryption via the "EncryptionDetails" property.
 saveOptions.setEncryptionDetails(encryptionDetails);

 // When we open this document, we will need to provide the password before accessing its contents.
 doc.save(getArtifactsDir() + "PdfSaveOptions.EncryptionPermissions.pdf", saveOptions);
 

Fields

FieldDescription
ALLOW_ALLAllows all operations on the PDF document.
CONTENT_COPYCopy or otherwise extract text and graphics from the document by operations other than that controlled by CONTENT_COPY_FOR_ACCESSIBILITY.
CONTENT_COPY_FOR_ACCESSIBILITYExtract text and graphics (in support of accessibility to users with disabilities or for other purposes).
DISALLOW_ALLDisallows all operations on the PDF document.
DOCUMENT_ASSEMBLYAssemble the document (insert, rotate, or delete pages and create document outline items or thumbnail images), even if MODIFY_CONTENTS is clear.
FILL_INFill in existing interactive form fields (including signature fields), even if MODIFY_CONTENTS is clear.
HIGH_RESOLUTION_PRINTINGPrint the document to a representation from which a faithful digital copy of the PDF content could be generated, based on an implementation-dependent algorithm.
MODIFY_ANNOTATIONSAdd or modify text annotations, fill in interactive form fields, and, if MODIFY_CONTENTS is also set, create or modify interactive form fields (including signature fields).
MODIFY_CONTENTSModify the contents of the document by operations other than those controlled by MODIFY_ANNOTATIONS, FILL_IN, and DOCUMENT_ASSEMBLY.
PRINTINGPrint the document (possibly not at the highest quality level, depending on whether HIGH_RESOLUTION_PRINTING is also set).
length

Methods

MethodDescription
fromName(String pdfPermissionsName)
fromNames(Set pdfPermissionsNames)
getName(int pdfPermissions)
getNames(int pdfPermissions)
getValues()
toString(int pdfPermissions)
toStringSet(int attr)

ALLOW_ALL

public static int ALLOW_ALL

Allows all operations on the PDF document.

CONTENT_COPY

public static int CONTENT_COPY

Copy or otherwise extract text and graphics from the document by operations other than that controlled by CONTENT_COPY_FOR_ACCESSIBILITY.

CONTENT_COPY_FOR_ACCESSIBILITY

public static int CONTENT_COPY_FOR_ACCESSIBILITY

Extract text and graphics (in support of accessibility to users with disabilities or for other purposes).

DISALLOW_ALL

public static int DISALLOW_ALL

Disallows all operations on the PDF document. This is the default value.

DOCUMENT_ASSEMBLY

public static int DOCUMENT_ASSEMBLY

Assemble the document (insert, rotate, or delete pages and create document outline items or thumbnail images), even if MODIFY_CONTENTS is clear.

FILL_IN

public static int FILL_IN

Fill in existing interactive form fields (including signature fields), even if MODIFY_CONTENTS is clear.

HIGH_RESOLUTION_PRINTING

public static int HIGH_RESOLUTION_PRINTING

Print the document to a representation from which a faithful digital copy of the PDF content could be generated, based on an implementation-dependent algorithm. When this flag is clear (and PRINTING is set), printing shall be limited to a low-level representation of the appearance, possibly of degraded quality.

MODIFY_ANNOTATIONS

public static int MODIFY_ANNOTATIONS

Add or modify text annotations, fill in interactive form fields, and, if MODIFY_CONTENTS is also set, create or modify interactive form fields (including signature fields).

MODIFY_CONTENTS

public static int MODIFY_CONTENTS

Modify the contents of the document by operations other than those controlled by MODIFY_ANNOTATIONS, FILL_IN, and DOCUMENT_ASSEMBLY.

PRINTING

public static int PRINTING

Print the document (possibly not at the highest quality level, depending on whether HIGH_RESOLUTION_PRINTING is also set).

length

public static int length

fromName(String pdfPermissionsName)

public static int fromName(String pdfPermissionsName)

Parameters:

ParameterTypeDescription
pdfPermissionsNamejava.lang.String

Returns: int

fromNames(Set pdfPermissionsNames)

public static int fromNames(Set pdfPermissionsNames)

Parameters:

ParameterTypeDescription
pdfPermissionsNamesjava.util.Set

Returns: int

getName(int pdfPermissions)

public static String getName(int pdfPermissions)

Parameters:

ParameterTypeDescription
pdfPermissionsint

Returns: java.lang.String

getNames(int pdfPermissions)

public static Set getNames(int pdfPermissions)

Parameters:

ParameterTypeDescription
pdfPermissionsint

Returns: java.util.Set

getValues()

public static int[] getValues()

Returns: int[]

toString(int pdfPermissions)

public static String toString(int pdfPermissions)

Parameters:

ParameterTypeDescription
pdfPermissionsint

Returns: java.lang.String

toStringSet(int attr)

public static String toStringSet(int attr)

Parameters:

ParameterTypeDescription
attrint

Returns: java.lang.String