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.
Summary of stepsTo remove password-based encryption from a PDF document,
perform the following steps:
Include project files
Create an encryption service client.
Get the encrypted PDF document.
Remove the password.
Save the PDF document as a PDF file.
Include project filesInclude 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 clientTo 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 documentYou 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 passwordTo 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 documentAfter 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 APIRemove password-based encryption from a PDF document by
using the Encryption API (Java):
Include project files.
Include client JAR files,
such as the adobe-encryption-client.jar, in your Java project’s
class path.
Create an encryption service client.
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.
Remove the password.
Remove password-based encryption
from the PDF document by invoking the EncryptionServiceClient object’s removePDFPasswordSecurity method
and passing the following values:
The removePDFPasswordSecurity method
returns a com.adobe.idp.Document object that contains
an unsecured PDF document.
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 APIRemove password-based encryption by using the Encryption
API (web service):
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.
注意: Replace localhost with the IP
address of the server hosting LiveCycle.
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.
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.
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.
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.
|
|
|