com.aspose.words

Class PdfEncryptionDetails

  • java.lang.Object
    • com.aspose.words.PdfEncryptionDetails
public class PdfEncryptionDetails 
extends java.lang.Object

Contains details for encrypting and access permissions for a PDF document.

Example:

Demonstrates how to set permissions on a PDF document generated by Aspose.Words.
Document doc = new Document(getMyDir() + "Rendering.doc");

PdfSaveOptions saveOptions = new PdfSaveOptions();

// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", "password", PdfEncryptionAlgorithm.RC_4_128);

// Start by disallowing all permissions.
encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);

// Extend permissions to allow editing or modifying annotations.
encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);
saveOptions.setEncryptionDetails(encryptionDetails);

// Render the document to PDF format with the specified permissions.
doc.save(getMyDir() + "\\Artifacts\\Rendering.SpecifyPermissions.pdf", saveOptions);

Constructor Summary
PdfEncryptionDetails(java.lang.StringuserPassword, java.lang.StringownerPassword, intencryptionAlgorithm)
Initializes an instance of this class.
 
Property Getters/Setters Summary
intgetEncryptionAlgorithm()
void
           Specifies the encryption algorithm to use. The value of the property is PdfEncryptionAlgorithm integer constant.
java.lang.StringgetOwnerPassword()
void
setOwnerPassword(java.lang.Stringvalue)
           Specifies the owner password for the encrypted PDF document.
intgetPermissions()
void
setPermissions(intvalue)
           Specifies the operations that are allowed to a user on an encrypted PDF document. The default value is PdfPermissions.DISALLOW_ALL. The value of the property is PdfPermissions integer constant.
java.lang.StringgetUserPassword()
void
setUserPassword(java.lang.Stringvalue)
           Specifies the user password required for opening the encrypted PDF document.
 

    • Constructor Detail

      • PdfEncryptionDetails

        public PdfEncryptionDetails(java.lang.String userPassword, java.lang.String ownerPassword, int encryptionAlgorithm)
        Initializes an instance of this class.
        Parameters:
        encryptionAlgorithm - A PdfEncryptionAlgorithm value.

        Example:

        Demonstrates how to set permissions on a PDF document generated by Aspose.Words.
        Document doc = new Document(getMyDir() + "Rendering.doc");
        
        PdfSaveOptions saveOptions = new PdfSaveOptions();
        
        // Create encryption details and set owner password.
        PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", "password", PdfEncryptionAlgorithm.RC_4_128);
        
        // Start by disallowing all permissions.
        encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
        
        // Extend permissions to allow editing or modifying annotations.
        encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);
        saveOptions.setEncryptionDetails(encryptionDetails);
        
        // Render the document to PDF format with the specified permissions.
        doc.save(getMyDir() + "\\Artifacts\\Rendering.SpecifyPermissions.pdf", saveOptions);
    • Property Getters/Setters Detail

      • getEncryptionAlgorithm/setEncryptionAlgorithm

        public int getEncryptionAlgorithm() / public void setEncryptionAlgorithm(int value)
        
        Specifies the encryption algorithm to use. The value of the property is PdfEncryptionAlgorithm integer constant.

        Example:

        Demonstrates how to set permissions on a PDF document generated by Aspose.Words.
        Document doc = new Document(getMyDir() + "Rendering.doc");
        
        PdfSaveOptions saveOptions = new PdfSaveOptions();
        
        // Create encryption details and set owner password.
        PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", "password", PdfEncryptionAlgorithm.RC_4_128);
        
        // Start by disallowing all permissions.
        encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
        
        // Extend permissions to allow editing or modifying annotations.
        encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);
        saveOptions.setEncryptionDetails(encryptionDetails);
        
        // Render the document to PDF format with the specified permissions.
        doc.save(getMyDir() + "\\Artifacts\\Rendering.SpecifyPermissions.pdf", saveOptions);
      • getOwnerPassword/setOwnerPassword

        public java.lang.String getOwnerPassword() / public void setOwnerPassword(java.lang.String value)
        
        Specifies the owner password for the encrypted PDF document.

        The owner password allows the user to open an encrypted PDF document without any access restrictions specified in Permissions.

        The owner password cannot be the same as the user password.

        Example:

        Demonstrates how to set permissions on a PDF document generated by Aspose.Words.
        Document doc = new Document(getMyDir() + "Rendering.doc");
        
        PdfSaveOptions saveOptions = new PdfSaveOptions();
        
        // Create encryption details and set owner password.
        PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", "password", PdfEncryptionAlgorithm.RC_4_128);
        
        // Start by disallowing all permissions.
        encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
        
        // Extend permissions to allow editing or modifying annotations.
        encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);
        saveOptions.setEncryptionDetails(encryptionDetails);
        
        // Render the document to PDF format with the specified permissions.
        doc.save(getMyDir() + "\\Artifacts\\Rendering.SpecifyPermissions.pdf", saveOptions);
      • getPermissions/setPermissions

        public int getPermissions() / public void setPermissions(int value)
        
        Specifies the operations that are allowed to a user on an encrypted PDF document. The default value is PdfPermissions.DISALLOW_ALL. The value of the property is PdfPermissions integer constant.

        Example:

        Demonstrates how to set permissions on a PDF document generated by Aspose.Words.
        Document doc = new Document(getMyDir() + "Rendering.doc");
        
        PdfSaveOptions saveOptions = new PdfSaveOptions();
        
        // Create encryption details and set owner password.
        PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", "password", PdfEncryptionAlgorithm.RC_4_128);
        
        // Start by disallowing all permissions.
        encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
        
        // Extend permissions to allow editing or modifying annotations.
        encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);
        saveOptions.setEncryptionDetails(encryptionDetails);
        
        // Render the document to PDF format with the specified permissions.
        doc.save(getMyDir() + "\\Artifacts\\Rendering.SpecifyPermissions.pdf", saveOptions);
      • getUserPassword/setUserPassword

        public java.lang.String getUserPassword() / public void setUserPassword(java.lang.String value)
        
        Specifies the user password required for opening the encrypted PDF document.

        The user password will be required to open an encrypted PDF document for viewing. The permissions specified in Permissions 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.

        Example:

        Demonstrates how to set permissions on a PDF document generated by Aspose.Words.
        Document doc = new Document(getMyDir() + "Rendering.doc");
        
        PdfSaveOptions saveOptions = new PdfSaveOptions();
        
        // Create encryption details and set owner password.
        PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", "password", PdfEncryptionAlgorithm.RC_4_128);
        
        // Start by disallowing all permissions.
        encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
        
        // Extend permissions to allow editing or modifying annotations.
        encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);
        saveOptions.setEncryptionDetails(encryptionDetails);
        
        // Render the document to PDF format with the specified permissions.
        doc.save(getMyDir() + "\\Artifacts\\Rendering.SpecifyPermissions.pdf", saveOptions);