java.lang.Objectcom.aspose.words.PdfEncryptionDetails
public class PdfEncryptionDetails
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello world!");
PdfEncryptionDetails encryptionDetails =
new PdfEncryptionDetails("password", "", PdfEncryptionAlgorithm.RC_4_128);
// Start by disallowing all permissions.
encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
// Extend permissions to allow the editing of annotations.
encryptionDetails.setPermissions(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 Summary |
---|
PdfEncryptionDetails(java.lang.String userPassword, java.lang.String ownerPassword, int encryptionAlgorithm)
Initializes an instance of this class. |
Property Getters/Setters Summary | ||
---|---|---|
int | getEncryptionAlgorithm() | |
void | setEncryptionAlgorithm(int value) | |
Specifies the encryption algorithm to use. The value of the property is PdfEncryptionAlgorithm integer constant. | ||
java.lang.String | getOwnerPassword() | |
void | setOwnerPassword(java.lang.String value) | |
Specifies the owner password for the encrypted PDF document. | ||
int | getPermissions() | |
void | setPermissions(int value) | |
Specifies the operations that are allowed to a user on an encrypted PDF document.
The default value is |
||
java.lang.String | getUserPassword() | |
void | setUserPassword(java.lang.String value) | |
Specifies the user password required for opening the encrypted PDF document. |
Constructor Detail |
---|
public PdfEncryptionDetails(java.lang.String userPassword, java.lang.String ownerPassword, int encryptionAlgorithm)
encryptionAlgorithm
- A PdfEncryptionAlgorithm value.Example:
Shows how to set permissions on a saved PDF document.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.writeln("Hello world!"); PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("password", "", PdfEncryptionAlgorithm.RC_4_128); // Start by disallowing all permissions. encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL); // Extend permissions to allow the editing of annotations. encryptionDetails.setPermissions(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);
Property Getters/Setters Detail |
---|
getEncryptionAlgorithm/setEncryptionAlgorithm | |
public int getEncryptionAlgorithm() / public void setEncryptionAlgorithm(int value) |
Example:
Shows how to set permissions on a saved PDF document.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.writeln("Hello world!"); PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("password", "", PdfEncryptionAlgorithm.RC_4_128); // Start by disallowing all permissions. encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL); // Extend permissions to allow the editing of annotations. encryptionDetails.setPermissions(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);
getOwnerPassword/setOwnerPassword | |
public java.lang.String getOwnerPassword() / public void setOwnerPassword(java.lang.String value) |
The owner password allows the user to open an encrypted PDF document without any access restrictions
specified in
The owner password cannot be the same as the user password.
Example:
Shows how to set permissions on a saved PDF document.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.writeln("Hello world!"); PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("password", "", PdfEncryptionAlgorithm.RC_4_128); // Start by disallowing all permissions. encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL); // Extend permissions to allow the editing of annotations. encryptionDetails.setPermissions(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);
getPermissions/setPermissions | |
public int getPermissions() / public void setPermissions(int value) |
Example:
Shows how to set permissions on a saved PDF document.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.writeln("Hello world!"); PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("password", "", PdfEncryptionAlgorithm.RC_4_128); // Start by disallowing all permissions. encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL); // Extend permissions to allow the editing of annotations. encryptionDetails.setPermissions(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);
getUserPassword/setUserPassword | |
public java.lang.String getUserPassword() / public void setUserPassword(java.lang.String value) |
The user password will be required to open an encrypted PDF document for viewing. The permissions specified in
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.
Example:
Shows how to set permissions on a saved PDF document.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.writeln("Hello world!"); PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("password", "", PdfEncryptionAlgorithm.RC_4_128); // Start by disallowing all permissions. encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL); // Extend permissions to allow the editing of annotations. encryptionDetails.setPermissions(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);