I am working on a project that requires submitting the content of the PDF document as a stream to a Servlet. For the most part, the project works fine – the form is posted by the Acrobat/Reader, the server receives the file, creates a local copy and processes it correctly. After the post is successfully received, the last step on the server is to send a reply to the Acrobat/Reader. On not receiving a reply, the Adobe Acrobat/Reader throws an unknown format error.
Reason of the problem is that the Adobe Acrobat/ Reader expect a return from the servlet and the application server was not generating a response that Acrobat/Reader understands. To remove the error message, the servlet should return a properly constructed FDF and the URL of the submit button should end with #FDF.
Note: I am using Adobe LiveCycle Designer; I believe you can use Adobe Acrobat to achieve the same result.
Here are the exact steps to remove the error:
- Open your XDP form in LiveCycle Designer.
- Select the Submit button.
- Either in the Design View or in the Source view, edit submit to URL to add #FDF at the end of the URL.
- Save the XDP.
- In your Java project, create a plain-text file and add the following content:
%FDF-1.2 1 0 obj << /FDF << /Status (Your message goes here.) >> >> endobj trailer << /Root 1 0 R >> %%EOF
- Replace “Your message goes here.” with the text you want to display.
- Save the file. For this example, let us save the file as returnresponse.txt
- Import returnresponse.txt to your Java project.
- Add the following code to your servlet:
response.setHeader("returnresponse.txt", "The file has been submitted sucessfully");
The Java code sets the MIME type of the response in the “Content-type” HTTP header to “application/vnd.fdf“.
- Run the program and you should not experience the error again.