These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Help about submit...is it possible to do this?

FranBCN
Registered: May 4 2008
Posts: 19
Answered

Hi, i am using Adobe Livecycle and a java-web based application running in a jboss server.
What i want is to submit the full pdf, and in the action servlet , do somethings and return an xml with
the data that has to be refilled the form. The same behaviour as a web application does. I thought in 2 possibilities:

1. with a FormCal function, i use

var result = get() or post()

in the result we get the xml returned from server and after i move data to the form. This is ok no problem.
The problem is how i can send the pdf with get() or post() function? is it possible?

2. with submitForm, but the problem here is that when i return the xml from the server, in the form appears
this xml! Is there a way to avoid this? Submitform doesnot wait for the server to answer. Also, what is the
way of retrieve the pdf submitted with java, anywhere to get some info would be appreciated 'cause i did not find anything.

I dont know if this is possible to do it with adobe, i need to know for using this tool. Thank you in advance.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Not only is this possible, but it's very common and done all the time.

The correct way to do this is to use "submitForm". This function sends an HTTP request to the server (with the specified data type in the body of the request) and waits for an HTTP response to return. Acrobat will only merge data back into the PDF if the return data is in the correct format (XDP) and the submission URL is postfixed with "#FDF". Also make sure that the MIME type in the HTTP Response Header is set correctly.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

eddieksyu
Registered: May 22 2008
Posts: 4
Hi Thomp,

I'm a newbie in LC form. I also want to do a pdf form submit to server. Happy that I can find the answer here. Now, my question is how can I return a reference number from the server to the form user? You mentioned that the return data should be in XDP format, how can I integrate this XDP data into a field in the user form to display the returned reference number to user? Please point me to the right way. Many Thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are several different data formats that Acrobat can intereact with, FDF, XFDF, XDP, etc. All of these data formats have one thing in common. In the simplest sense, they are all lists of name/value pairs. Where the name bit is the name of a form field on the PDF file. To use one of these data files to return data to your form from a server you have to know three things. 1) The names of the fields on your form. 2) The details of data format you'll be using. 3) How Acrobat merges the data in the data file into the form. This is different for different data formats and different form technologies.

To find out how the XDP should be formatted for the results you want, first fill out the form in the disired way. Then export the form data to XDP from the "Forms->manage form data" menu item. This file will be in exactly the correct format for returning data from the server script to your form.To get this to work from the server you'll need to make one modification. You need to remove the file reference from the XDP that's exported from Acrobat.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

eddieksyu
Registered: May 22 2008
Posts: 4
Thanks Thomp for your prompt reply.

If I use FDF for the return format, and just simply use the following script:

this.submitForm({
cURL: "http://www.example.com/cgi-bin/myscript.cgi#FDF",
cSubmitAs: "PDF"
});

Will the return data in FDF format automatically merged into the form and display the result?

OR do I need the write something like:

var returnFDF = this.submitForm({
cURL: "http://www.example.com/cgi-bin/myscript.cgi#FDF",
cSubmitAs: "XFDF"
});

And then manipulate the returnFDF variable?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The submitted data is completely separate from what comes back. They can be different formats. It's all in the mime type of the HTTP response.

However, since you're using a LC form and returning FDF you have to be careful about the form field names. But yes, the FDF data should be merged into the LC form.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

eddieksyu
Registered: May 22 2008
Posts: 4
Hi Thomp,

I have tried many different format for the field name such as

fieldname, form1.subform[0].fieldname etc in the return FDF. To my

disappointment, all failed. Could you please kindly give me some hint?
deepakchajlan
Registered: May 29 2008
Posts: 2
hi how i can submit pdf form via ftp and http in pdf format
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
eddieksyu - Try this experiment. Export your form to FDF using the submitForm() fucntion like this

this.submitForm({
cURL: "mailto:me [at] mine [dot] com",
cSubmitAs: "PDF",
cCharsEt: "utf-8"
});

This will display your email client. Save the attached file to your disk. Now change the data on the form and import the FDF file from the console window using the "this.importAnFDF()" function.

If the form data changes to match what's saved in the FDF file then the names you need for the form are correct in that file. If not, then you'll have to stick to returning XDP from the server.


Deepakchajlan: Acrobat does not implement the FTP protocal. Forms can be submitted only by HTTP. Read this article:

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/submitting_data/

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

FranBCN
Registered: May 4 2008
Posts: 19
it only works with adobe static forms, how can i do it with dynamic forms?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
What exactly isn't working? Submitting and returning data from/to a dynamic form uses the same functions, but works slightly differently because a dynamic form can have multiple copies of the same fields. XDP and generic XML are designed to specifically handle this situation. So these are the best formats to use with a dynamic LiveCycle form. The other data formats should also be painlessly recieved by Acrobat, but without handling multiple copies of the same data.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

FranBCN
Registered: May 4 2008
Posts: 19
the same pdf, if i save it as "Static Form" , after press submit i receive the data as fdf ok, and it is shown in my document. But if i save it as "Dynamic Form" i dont see the fields filled with the data returned from the server, as i see when the document is "Static". I read in some forums that FDF does not work with LC 8.0 because is a deprecated api. How is it suposed to do with LC 8.0? thanx
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Well then, you either have to use XDP or a static form. XDP is pretty easy to generate. Export data from the form as XDP from the "Forms" menu in Acrobat Pro to see what it looks like.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script