I have an AcroForm in a PDF file made with Acrobat 7.
It has a Send button that calls a simple JavaScript that does a submitForm() and sends form field data in FDF format to a Java Tomcat server. My Java servlet gets the posted data and saves it in a database.
So far, so good! But what should the servlet's response to the HTTP post operation be?
If I send nothing back, the browser window shows a blank page.
If I send a web page back, the webpage is displayed and the user needs to hit the browser's back button to return to the PDF file.
If I send the FDF back as the response, the original PDF file remains visible but the FDF file is simply saved as a download with its name given as the servlet name.
What I want is for the original PDF to continue to be visible and when the submitForm() call completes to display a dialog saying that the save succeeded or else giving an error message.
There is a total black hole when it comes to finding out the options for this kind of situation.
Can ayone help?
thanks,
Terry
When you submit to your server, you need to ensure that your URL has a #FDF at the end of it so the browser knows to receive a response in FDF format, otherwise the native action is to go to that page. In Acrobat, or the desktop Reader version, FDF is the only response they will receive readily. If an HTML response is received, Acrobat will convert that into a new PDF, and reader will just fail entirely telling you it doesn't know how to deal with text/html. Any other response to Acrobat and the Desktop reader will say it's an unknown response type.
To address this:
This is the header output that tells the browser/server to send a response as an FDF. I don't use Java for my server side language of choice, but rather PHP, so this answer is based on my experience with how PHP sends an FDF back into the PDF. How you generate the FDF is up to you, whether you have it in a predefined format, or generate it on the fly using the FDF-toolkit Adobe provides. [url=http://www.adobe.com/devnet/acrobat/fdftoolkit.php]This is the FDF-toolkit released by Adobe for Java[/url]
To better understand the FDF, and how to send various responses back, I'd suggest reading the [url=http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf]PDF Reference 1.6 (PDF v7)[/url].