You can
use the Output service to transform an interactive PDF document
to a non-interactive PDF. An interactive PDF document lets users
enter or modify data that is in the PDF document fields. The process
of transforming an interactive PDF document to a non-interactive
PDF document is called
flattening
. When a PDF document is flattened,
a user cannot modify the data in the document fields. One reason
to flatten a PDF document is to ensure that data cannot be modified.
You can flatten the following types of PDF documents:
Attempting to flatten a PDF that is a non-interactive PDF document
causes an exception.
Summary of steps
To flatten an interactive PDF document
to a non-interactive PDF document, perform the following steps:
-
Include project files.
-
Create an Output Client object.
-
Retrieve an interactive PDF document.
-
Transform the PDF document.
-
Save the non-interactive PDF document as a PDF file.
Include project files
Include the necessary files in your development
project. If you are creating a client application by using Java,
include the necessary JAR files. If you are by 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-output-client.jar
-
adobe-utilities.jar (required if LiveCycle is deployed
on JBoss)
-
jbossall-client.jar (required if LiveCycle is deployed
on JBoss)
if LiveCycle is deployed on a
supported J2EE application server that is not JBoss, you will need
to replace the adobe-utilities.jar and jbossall-client.jar files
with JAR files that are specific to the J2EE application server
on which LiveCycle is deployed. For information about the
location of all LiveCycle JAR files, see
Including LiveCycle Java library files
.
Create an Output Client object
Before you can programmatically
perform an Output service operation, you must create an Output service
client object. If you are using the Java API, create an
OutputClient
object.
If you are using the Output web service API, create an
OutputServiceService
object.
Retrieve an interactive PDF document
Retrieve an interactive PDF
document that you want to transform to a non-interactive PDF document.
Attempting to transform a non-interactive PDF document, causes an
exception.
Transform the PDF document
After you retrieve an interactive PDF
document, you can transform it to a non-interactive PDF document.
The Output service returns a non-interactive PDF document.
Save the non-interactive PDF document as a PDF file
You can
save the non-interactive PDF document as a PDF file.
Flatten a PDF document using the Java API
Flatten an interactive PDF document to a non-interactive
PDF document by using the Output API (Java):
-
Include project files.
Include client JAR files,
such as adobe-output-client.jar, in your Java project’s class path.
-
Create an Output Client object.
-
Retrieve an interactive PDF document.
-
Create
a
java.io.FileInputStream
object that represents
the interactive PDF document to transform by using its constructor and
passing a string value that specifies the location of the interactive
PDF file.
-
Create a
com.adobe.idp.Document
object by
using its constructor and passing the
java.io.FileInputStream
object.
-
Transform the PDF document.
Transform the interactive
PDF document to a non-interactive PDF document by invoking the
OutputServiceService
object’s
transformPDF
method
and passing the following values:
-
The
com.adobe.idp.Document
object
that contains the interactive PDF document.
-
A
TransformationFormat
enum value. To generate
a non-interactive PDF document, specify
TransformationFormat.PDF
.
-
A
PDFARevisionNumber
enum value that specifies
the revision number. Because this parameter is meant for a PDF/A
document, you can specify
null
.
-
A string value that represents the amendment number and year, separated
by a colon. Because this parameter is meant for a PDF/A document,
you can specify
null
.
-
A
PDFAConformance
enum value that represents
the PDF/A conformance level. Because this parameter is meant for
a PDF/A document, you can specify
null
.
The
transformPDF
method
returns a
com.adobe.idp.Document
object that contains
a non-interactive PDF document.
-
Save the non-interactive PDF document as a PDF file.
-
Create a
java.io.File
object and ensure
that the file name extension is .pdf.
-
Invoke the
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
transformPDF
method).
Flatten a PDF document using the web service API
Flatten an interactive PDF document to a non-interactive
PDF document by using the Output 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/OutputService?WSDL&lc_version=9.0.1
.
Note:
Replace
localhost
with the IP
address of the server hosting LiveCycle.
-
Create an Output Client object.
-
Create an
OutputServiceClient
object
by using its default constructor.
-
Create an
OutputServiceClient.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/OutputService?blob=mtom
.)
You do not need to use the
lc_version
attribute.
This attribute is used when you create a service reference. However,
specify
?blob=mtom
to use MTOM.
-
Create a
System.ServiceModel.BasicHttpBinding
object
by getting the value of the
OutputServiceClient.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 AEM forms user name to the field
OutputServiceClient.ClientCredentials.UserName.UserName
.
-
Assign the corresponding password value to the field
OutputServiceClient.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
.
-
Retrieve an interactive PDF document.
-
Create
a
BLOB
object by using its constructor. The
BLOB
object
is used to store the interactive PDF document.
-
Create a
System.IO.FileStream
object by
invoking its constructor and passing a string value that represents the
file location of the interactive PDF document.
-
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 its
MTOM
property
with the contents of the byte array.
-
Transform the PDF document.
Transform the interactive
PDF document to a non-interactive PDF document by invoking the
OutputClient
object’s
transformPDF
method
and passing the following values:
-
A
BLOB
object
that contains the interactive PDF document.
-
A
TransformationFormat
enumeration value.
To generate a non-interactive PDF document, specify
TransformationFormat.PDF
.
-
A
PDFARevisionNumber
enum value that specifies
the revision number.
-
A Boolean value that specifies whether the
PDFARevisionNumber
enum
value is used. Because this parameter is meant for a PDF/A document,
you can specify
false
.
-
A string value that represents the amendment number and year, separated
by a colon. Because this parameter is meant for a PDF/A document,
you can specify
null
.
-
A
PDFAConformance
enum value that represents
the PDF/A conformance level.
-
Boolean value that specifies whether the
PDFAConformance
enum
value is used. Because this parameter is meant for a PDF/A document,
you can specify
false
.
The
transformPDF
method
returns a
BLOB
object that contains a non-interactive
PDF document.
-
Save the non-interactive PDF document as a PDF file.
-
Create a
System.IO.FileStream
object by
invoking its constructor and passing a string value that represents the
file location of the non-interactive PDF document.
-
Create a byte array that stores the data content of the
BLOB
object
that was returned by the
transformPDF
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.
|
|
|