Applying Policies to PDF Documents

You can apply a policy to a PDF document in order to secure the document. By applying a policy to a PDF document, you restrict access to the document. You cannot apply a policy to a document if the document is already secured with a policy.

While the document is open, you can also restrict access to Acrobat and Adobe Reader features, including the ability to print and copy text, make changes, and add signatures and comments to a document. In addition, you can revoke a policy-protected PDF document when you no longer want users to access the document.

You can monitor the use of a policy-protected document after you distribute it. That is, you can see how the document is being used and who is using it. For example, you can find out when somebody has opened the document.

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

Summary of steps

To apply a policy to a PDF document, perform the following steps:

  1. Include project files.

  2. Create a Rights Management Client API object.

  3. Retrieve a PDF document to which a policy is applied.

  4. Apply an existing policy to the PDF document.

  5. Save the policy-protected PDF document.

Include project files

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

Create a Rights Management Client APIobject

Before you can programmatically perform a Rights Management service operation, create a Rights Management service client object. If you are using the Java API, create a RightsManagementClient object. If you are using the Rights Management web service API, create a RightsManagementServiceService object.

Retrieve a PDF document

You can retrieve a PDF document in order to apply a policy. After you apply a policy to the PDF document, users are restricted when using the document. For example, if the policy does not enable the document to be opened while offline, then users must be online to open the document.

Apply an existing policy to the PDF document

To apply a policy to a PDF document, reference an existing policy and specify which policy set the policy belongs to. The user who is setting the connection properties must have access to the specified policy. If not, an exception occurs.

Save the PDF document

After the Rights Management service applies a policy to a PDF document, you can save the policy-protected PDF document as a PDF file.

Apply a policy to a PDF document using the Java API

Apply a policy to a PDF document by using the Rights Management API (Java):

  1. Include project files.

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

  2. Create a Rights Management Client API object.

    • Create a ServiceClientFactory object that contains connection properties.

    • Create a RightsManagementClient object by using its constructor and passing the ServiceClientFactory object.

  3. Retrieve a PDF document.

    • Create a java.io.FileInputStream object that represents the PDF document by using its constructor. Pass 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. Apply an existing policy to the PDF document.

    • Create a DocumentManager object by invoking the RightsManagementClient object’s getDocumentManager method.

    • Apply a policy to the PDF document by invoking the DocumentManager object’s protectDocument method and passing the following values:

      • The com.adobe.idp.Document object that contains the PDF document to which the policy is applied.

      • A string value that specifies the name of the document.

      • A string value that specifies the name of the policy set to which the policy belongs. You can specify a null value that results in the MyPolicies policy set being used.

      • A string value that specifies the policy name.

      • A string value that represents the name of the user manager domain of the user who is the publisher of the document. This parameter value is optional and can be null (if this parameter is null, then the next parameter value must be null).

      • A string value that represents the name of the canonical name of the user manager user who is the publisher of the document. This parameter value is optional and can be null (if this parameter is null, then the previous parameter value must be null).

      • A com.adobe.livecycle.rightsmanagement.Locale that represents the locale that is used for selecting the MS Office template. This parameter value is optional and not used for PDF documents. To secure a PDF document, specify null.

      The protectDocument method returns a RMSecureDocumentResult object that contains the policy-protected PDF document.

  5. Save the PDF document.

    • Invoke the RMSecureDocumentResult object’s getProtectedDoc method to get the policy-protected PDF document. This method returns a com.adobe.idp.Document object.

    • Create a java.io.File object and ensure that the file 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 getProtectedDoc method).

Code examples

For code examples using the Rights Management service, see the following Quick Starts in API Quick Starts (Code Examples):

  • “Quick Start (EJB mode): Applying a policy to a PDF document using the Java API”

  • “Quick Start (SOAP mode): Applying a policy to a PDF document using the Java API”

Apply a policy to a PDF document using the web service API

Apply a policy to a PDF document by using the Rights Management 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/RightsManagementService?WSDL&lc_version=9.0.1.

    Hinweis: Replace localhost with the IP address of the server hosting LiveCycle.
  2. Create a Rights Management Clinet API object.

    • Create a RightsManagementServiceClient object by using its default constructor.

    • Create a RightsManagementServiceClient.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/RightsManagementService?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 RightsManagementServiceClient.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 RightsManagementServiceClient.ClientCredentials.UserName.UserName.

      • Assign the corresponding password value to the field RightsManagementServiceClient.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. Retrieve a PDF document.

    • Create a BLOB object by using its constructor. The BLOB object is used to store a PDF document to which a policy is applied.

    • Create a System.IO.FileStream object by invoking its constructor and passing a string value that represents the file location of the 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. Determine the byte array size 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. Pass the byte array, the starting position, and the stream length to read.

    • Populate the BLOB object by assigning its MTOM field with the contents of the byte array.

  4. Apply an existing policy to the PDF document.

    Apply a policy to the PDF document by invoking the RightsManagementServiceClient object’s protectDocument method and passing the following values:

    • The BLOB object that contains the PDF document to which the policy is applied.

    • A string value that specifies the name of the document.

    • A string value that specifies the name of the policy set to which the policy belongs. You can specify a null value that results in the MyPolicies policy set being used.

    • A string value that specifies the policy name.

    • A string value that represents the name of the user manager domain of the user who is the publisher of the document. This parameter value is optional and can be null (if this parameter is null, then the next parameter value must be null).

    • A string value that represents the name of the canonical name of the user manager user who is the publisher of the document. This parameter value is optional and can be null (if this parameter is null, then the previous parameter value must be null).

    • A RMLocale value that specifies the locale value (for example, RMLocale.en).

    • A string output parameter that is used to store the policy identifier value.

    • A string output parameter that is used to store the policy-protected identifier value.

    • A string output parameter that is used to store the mime type (for example, application/pdf).

    The protectDocument method returns a BLOB object that contains the policy-protected 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 policy-protected PDF document.

    • Create a byte array that stores the data content of the BLOB object that was returned by the protectDocument 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.

Code examples

For code examples using the Rights Management service, see the following Quick Starts in API Quick Starts (Code Examples):

  • “Quick Start (MTOM): Applying a policy to a PDF document using the web service API”

  • “Quick Start (SwaRef): Applying a policy to a PDF document using the web service API ”