To create a PDF document, perform
the following steps:
Include project files.
Create an Output Client object.
Reference an XML data source.
Set PDF run-time options.
Set rendering run-time options.
Generate a PDF document.
Retrieve the results of the operation.
Include project files
Include necessary files in your development
project. If you are creating a client application by 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 classpath:
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.
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.
Reference an XML data source
To merge data with the form design,
you must reference an XML data source that contains data. An XML
element must exist for every form field that you plan to populate
with data. The XML element name must match the field name. An XML
element is ignored if it does not correspond to a form field or
if the XML element name does not match the field name. It is not
necessary to match the order in which the XML elements are displayed
if all XML elements are specified.
Consider the following
example loan application form.
To
merge data into this form design, you must create an XML data source that
corresponds to the form. The following XML represents an XDP XML
data source that corresponds to the example mortgage application
form.
<?xml version="1.0" encoding="UTF-8" ?>
- <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
- <xfa:data>
- <data>
- <Layer>
<closeDate>1/26/2007</closeDate>
<lastName>Johnson</lastName>
<firstName>Jerry</firstName>
<mailingAddress>JJohnson@NoMailServer.com</mailingAddress>
<city>New York</city>
<zipCode>00501</zipCode>
<state>NY</state>
<dateBirth>26/08/1973</dateBirth>
<middleInitials>D</middleInitials>
<socialSecurityNumber>(555) 555-5555</socialSecurityNumber>
<phoneNumber>5555550000</phoneNumber>
</Layer>
- <Mortgage>
<mortgageAmount>295000.00</mortgageAmount>
<monthlyMortgagePayment>1724.54</monthlyMortgagePayment>
<purchasePrice>300000</purchasePrice>
<downPayment>5000</downPayment>
<term>25</term>
<interestRate>5.00</interestRate>
</Mortgage>
</data>
</xfa:data>
</xfa:datasets>
Set PDF run-time options
Set the file URI option when creating
a PDF document. This option specifies the name and location of the
PDF file that the Output service generates.
注意: Instead
of setting the file URI run-time option, you can programmatically
retrieve the PDF document from the complex data type that is returned
by the Output service. However, by setting the file URI run-time
option, you do not need to create application logic that programmatically
retrieves the PDF document.
Set rendering run-time options
You can set rendering run-time
options when creating a PDF document. Although these options are
not required (unlike PDF run-time options that are required), you
can perform tasks such as improving the performance of the Output
service. For example, you can cache the form design that the Output service
uses in order to improve its performance.
If you use a tagged
Acrobat form as input, you cannot use the Output service Java or
web service API to turn off the tagged setting. If you attempt to
programmatically set this option to false, the
result PDF document is still tagged.
注意: If you
do not specify rendering run-time options, then default values are
used. For information about rendering run-time options, see the
RenderOptionsSpec class
reference. (See
LiveCycle API Reference).
Generate a PDF document
After you reference a valid XML data source
that contains form data and you set run-time options, you can invoke
the Output service, which results in it generating a PDF document.
When
generating a PDF document, you specify URI values that are required by
the Output service to create a PDF document. A form design can be
stored in locations such as the server file system or as part of
a LiveCycle application. A form design (or other resources
such as an image file) that exists as part of a LiveCycle
application can be referenced by using the content root URI value repository:///.
For example, consider the following form design named Loan.xdp located
within a LiveCycle application named Applications/FormsApplication:
To
access the Loan.xdp file shown in the previous illustration, specify repository:///Applications/FormsApplication/1.0/FormsFolder/ as
the third parameter passed to the OutputClient object’s generatePDFOutput method.
Specify the form name (Loan.xdp) as the second parameter
passed to the OutputClient object’s generatePDFOutput method.
If
the XDP file contains images (or other resources such as fragments),
place the resources in the same application folder as the XDP file.
LiveCycle uses the content root URI as the base path to
resolve references to images. For example, if the Loan.xdp file
contains an image, ensure that you place the image in Applications/FormsApplication/1.0/FormsFolder/.
注意: You can reference a LiveCycle application
URI when invoking the OutputClient object’s generatePDFOutput or generatePrintedOutput methods.
Retrieve the results of the operation
After the Output service
performs an operation, it returns various data items such as status
XML data that specifies whether the operation was successful.