Removing Password Encryption

Password-based encryption can be removed from a PDF document so that users can open the PDF document in Adobe Reader or Acrobat without having to specify a password. After password-based encryption is removed from a PDF document, the document is no longer secure.

Hinweis: For more information about the Encryption service, see Services Reference for LiveCycle.

Summary of steps

To remove password-based encryption from a PDF document, perform the following steps:

  1. Include project files

  2. Create an encryption service client.

  3. Get the encrypted PDF document.

  4. Remove the password.

  5. Save the PDF document as a PDF file.

Include project files

Include the necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, make sure that you include the proxy files.

The following JAR files must be added to your project’s class path:

  • adobe-livecycle-client.jar

  • adobe-usermanager-client.jar

  • adobe-encryption-client.jar

  • adobe-utilities.jar (required if LiveCycle is deployed on JBoss)

  • jbossall-client.jar (required if LiveCycle is deployed on JBoss)

Create an encryption service client

To programmatically perform an Encryption service operation, you must create an Encryption service client. If you are using the Java Encryption Service API, create an EncrytionServiceClient object. If you are using the web service Encryption Service API, create an EncryptionServiceService object.

Get the encrypted PDF document

You must obtain an encrypted PDF document to remove password-based encryption. If you attempt to remove encryption from a PDF document that is not encrypted, an exception is thrown.

Remove the password

To remove password-based encryption from an encrypted PDF document, you require both an encrypted PDF document and a master password value that is used to remove encryption from the PDF document. The password that is used to open a password-encrypted PDF document cannot be used to remove encryption. A master password is specified when the PDF document is encrypted with a password. (See Encrypting PDF Documents with a Password.)

Save the PDF document

After the Encryption service removes password-based encryption from a PDF document, you can save the PDF document as a PDF file. Users can open the PDF document in Adobe Reader or Acrobat without specifying a password.

Remove password-based encryption using the Java API

Remove password-based encryption from a PDF document by using the Encryption API (Java):

  1. Include project files.

    Include client JAR files, such as the adobe-encryption-client.jar, in your Java project’s class path.

  2. Create an encryption service client.

    • Create a ServiceClientFactory object that contains connection properties.

    • Create an EncryptionServiceClient object by using its constructor and passing the ServiceClientFactory object.

  3. Get the encrypted PDF document.

    • Create a java.io.FileInputStream object that represents the encrypted PDF document by using its constructor and passing a string value that specifies the location of the PDF document.

    • Create a com.adobe.idp.Document object by using its constructor and passing the java.io.FileInputStream object.

  4. Remove the password.

    Remove password-based encryption from the PDF document by invoking the EncryptionServiceClient object’s removePDFPasswordSecurity method and passing the following values:

    • A com.adobe.idp.Document object that contains the encrypted PDF document.

    • A string value that specifies the master password value that is used to remove encryption from the PDF document.

    The removePDFPasswordSecurity method returns a com.adobe.idp.Document object that contains an unsecured PDF document.

  5. Save the PDF document.

    • Create a java.io.File object and ensure that the file name extension is .pdf.

    • Invoke the com.adobe.idp.Document object’s copyToFile method to copy the contents of the Document object to the file. Ensure that you use the Document object that was returned by the removePDFPasswordSecurity method.

Remove password-based encryption using the web service API

Remove password-based encryption by using the Encryption API (web service):

  1. Include project files.

    Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/EncryptionService?WSDL&lc_version=9.0.1.

    Hinweis: Replace localhost with the IP address of the server hosting LiveCycle.
  2. Create an encryption service client.

    • Create an EncryptionServiceClient object by using its default constructor.

    • Create an EncryptionServiceClient.Endpoint.Address object by using the System.ServiceModel.EndpointAddress constructor. Pass a string value that specifies the WSDL to the LiveCycle service (for example, http://localhost:8080/soap/services/EncryptionService?WSDL.) You do not need to use the lc_version attribute. This attribute is used when you create a service reference.)

    • Create a System.ServiceModel.BasicHttpBinding object by getting the value of the EncryptionServiceClient.Endpoint.Binding field. Cast the return value to BasicHttpBinding.

    • Set the System.ServiceModel.BasicHttpBinding object’s MessageEncoding field to WSMessageEncoding.Mtom. This value ensures that MTOM is used.

    • Enable basic HTTP authentication by performing the following tasks:

      • Assign the LiveCycle user name to the field EncryptionServiceClient.ClientCredentials.UserName.UserName.

      • Assign the corresponding password value to the field EncryptionServiceClient.ClientCredentials.UserName.Password.

      • Assign the constant value HttpClientCredentialType.Basic to the field BasicHttpBindingSecurity.Transport.ClientCredentialType.

      • Assign the constant value BasicHttpSecurityMode.TransportCredentialOnly to the field BasicHttpBindingSecurity.Security.Mode.

  3. Get the encrypted PDF document.

    • Create a BLOB object by using its constructor. The BLOB object is used to store a password-encrypted PDF document.

    • Create a System.IO.FileStream object by invoking its constructor and passing a string value that represents the file location of the encrypted PDF document and the mode in which to open the file.

    • Create a byte array that stores the content of the System.IO.FileStream object. You can determine the size of the byte array by getting the System.IO.FileStream object’s Length property.

    • Populate the byte array with stream data by invoking the System.IO.FileStream object’s Read method and passing the byte array, the starting position, and the stream length to read.

    • Populate the BLOB object by assigning the contents of the byte array to the BLOB object’s MTOM data member.

  4. Remove the password.

    Invoke the EncryptionServiceService object’s removePDFPasswordSecurity method and pass the following values:

    • The BLOB object that contains file stream data that represents an encrypted PDF document.

    • A string value that specifies the password value that is used to remove encryption from the PDF document. This value is specified when encrypting the PDF document with a password.

    The removePDFPasswordSecurity method returns a BLOB object that contains an unsecured PDF document.

  5. Save the PDF document.

    • Create a System.IO.FileStream object by invoking its constructor and passing a string value that represents the file location of the unsecured PDF document.

    • Create a byte array that stores the content of the BLOB object that was returned by the removePDFPasswordSecurity method. Populate the byte array by getting the value of the BLOB object’s MTOM data member.

    • Create a System.IO.BinaryWriter object by invoking its constructor and passing the System.IO.FileStream object.

    • Write the contents of the byte array to a PDF file by invoking the System.IO.BinaryWriter object’s Write method and passing the byte array.