Take a survey

Developing Applications Using APIs > Rendering Forms > Handling Submitted Forms > Handling submitted PDF data using the web service API

Handling submitted PDF data using the web service API
To handle a submitted form using the web service API, perform the following tasks:
1.
2.
Create a FormsService object and set authentication values.
3.
Create a java.io.InputStream object by invoking the javax.servlet.http.HttpServletResponse object’s getInputStream method.
Create a java.io.ByteArrayOutputStream object by using its constructor and passing the length of the java.io.InputStream object.
Copy the contents of the java.io.InputStream object into the java.io.ByteArrayOutputStream object.
Create a byte array by invoking the java.io.ByteArrayOutputStream object’s toByteArray method.
Populate the BLOB object by invoking its setBinaryData method and passing the byte array as an argument.
Create a RenderOptionsSpec object by using its constructor. Set the locale value by invoking the RenderOptionsSpec object’s setLocale method and passing a string value that specifies the locale value.
Invoke the FormsService object’s processFormSubmission method and pass the following values:
The BLOB object that contains the form data.
A string value that specifies environment variables included all relevant HTTP headers. For example, you can specify the following string value:
HTTP_REFERER=referrer&HTTP_CONNECTION=keep-alive&
CONTENT_TYPE=application/xml
A string value that specifies the HTTP_USER_AGENT header value; for example, Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322).
A RenderOptionsSpec object that stores run-time options. For information about this object, see the LiveCycle ES API References.
An empty BLOBHolder object that is populated by the method.
An empty javax.xml.rpc.holders.StringHolder object that is populated by the method.
An empty BLOBHolder object that is populated by the method.
An empty BLOBHolder object that is populated by the method.
An empty javax.xml.rpc.holders.ShortHolder object that is populated by the method.
An empty MyArrayOf_xsd_anyTypeHolder object that is populated by the method. This parameter is used to store file attachments that are submitted along with the form.
An empty FormsResultHolder object that is populated by the method with the form that is submitted.
The processFormSubmission method populates the FormsResultHolder parameter with the results of the form submission.
Determine whether the Forms service is finished processing the form data by invoking the FormsResult object’s getAction method. If this method returns the value 0, the form data is ready to be processed. You can get a FormsResult object by getting the value of the FormsResultHolder object’s value data member.
4.
Get the value of the MyArrayOf_xsd_anyTypeHolder object’s value data member (the MyArrayOf_xsd_anyTypeHolder object was passed to the processFormSubmission method). This data member returns an array of Objects. Each element within the Object array is an Object that corresponds to the files that were submitted along with the form. You can get each element within the array and cast it to a BLOB object.
5.
To determine the form data content type, invoke the FormsResult object’s getContentType method. This method returns a string value that specifies the content type of the submitted form data. If XML data is submitted to the Forms service, as opposed to PDF data, this method returns application/vnd.adobe.xdp+xml.
6.
If the data content type is application/vnd.adobe.xdp+xml or text/xml, create application logic to retrieve XML data values.
Create a BLOB object by invoking the FormsResult object’s getOutputContent method.
Create a byte array by invoking the BLOB object’s getBinaryData method.
Create a java.io.InputStream object by invoking the java.io.ByteArrayInputStream constructor and passing the byte array.
Create an org.w3c.dom.DocumentBuilderFactory object by calling the static org.w3c.dom.DocumentBuilderFactory object’s newInstance method.
Create an org.w3c.dom.DocumentBuilder object by invoking the org.w3c.dom.DocumentBuilderFactory object’s newDocumentBuilder method.
Create an org.w3c.dom.Document object by invoking the org.w3c.dom.DocumentBuilder object’s parse method and passing the java.io.InputStream object.
Retrieve the value of each node within the XML document. One way to accomplish this task is to create a custom method that accepts two parameters: the org.w3c.dom.Document object and the name of the node whose value you want to retrieve. This method returns a string value representing the value of the node. In the code example that follows this process, this custom method is called getNodeText. The body of this method is shown.
If the data content type is application/pdf, create application logic to save the submitted PDF data as a PDF file.
Create a BLOB object by invoking the FormsResult object’s getOutputContent method.
Create a byte array by invoking the BLOB object’s getBinaryData method.
Create a java.io.File object by using its public constructor. Be sure to specify PDF as the file name extension.
Create a java.io.FileOutputStream object by using its constructor and passing the java.io.File object.
Populate the PDF file by invoking the java.io.FileOutputStream object’s write method and passing the byte array.
View Quick Start
 

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/renderingSubmitting.39.4.html