public class PdfEncryptionDetails
extends java.lang.Object
To learn more, visit the Protect or Encrypt a Document documentation article.
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);
| Constructor and Description |
|---|
PdfEncryptionDetails(java.lang.String userPassword,
java.lang.String ownerPassword)
Initializes an instance of this class.
|
PdfEncryptionDetails(java.lang.String userPassword,
java.lang.String ownerPassword,
int permissions)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getOwnerPassword()
Specifies the owner password for the encrypted PDF document.
|
int |
getPermissions()
Specifies the operations that are allowed to a user on an encrypted PDF document.
|
java.lang.String |
getUserPassword()
Specifies the user password required for opening the encrypted PDF document.
|
void |
setOwnerPassword(java.lang.String value)
Specifies the owner password for the encrypted PDF document.
|
void |
setPermissions(int value)
Specifies the operations that are allowed to a user on an encrypted PDF document.
|
void |
setUserPassword(java.lang.String value)
Specifies the user password required for opening the encrypted PDF document.
|
public PdfEncryptionDetails(java.lang.String userPassword,
java.lang.String ownerPassword)
public PdfEncryptionDetails(java.lang.String userPassword,
java.lang.String ownerPassword,
int permissions)
public java.lang.String getUserPassword()
Remarks:
The user password will be required to open an encrypted PDF document for viewing. The permissions specified in getPermissions() / setPermissions(int) will be enforced by the reader software.
The user password can be null or empty string, in this case no password will be required from the user when opening the PDF document. The user password cannot be the same as the owner password.
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);
String value.public void setUserPassword(java.lang.String value)
Remarks:
The user password will be required to open an encrypted PDF document for viewing. The permissions specified in getPermissions() / setPermissions(int) will be enforced by the reader software.
The user password can be null or empty string, in this case no password will be required from the user when opening the PDF document. The user password cannot be the same as the owner password.
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);
value - The corresponding String value.public java.lang.String getOwnerPassword()
Remarks:
The owner password allows the user to open an encrypted PDF document without any access restrictions specified in getPermissions() / setPermissions(int).
The owner password cannot be the same as the user password.
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);
String value.public void setOwnerPassword(java.lang.String value)
Remarks:
The owner password allows the user to open an encrypted PDF document without any access restrictions specified in getPermissions() / setPermissions(int).
The owner password cannot be the same as the user password.
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);
value - The corresponding String value.public int getPermissions()
PdfPermissions.DISALLOW_ALL.
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);
int value. The returned value is a bitwise combination of PdfPermissions constants.public void setPermissions(int value)
PdfPermissions.DISALLOW_ALL.
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);
value - The corresponding int value. The value must be a bitwise combination of PdfPermissions constants.