vigneshwerv
vigneshwerv

Reputation: 155

Passing form data from PDF to a servlet in iText

I have a PDF that contains a form that should be filled by users that transfers the submitted data to a database. For example, it contains the name, age, and comments fields. The user fills out this form and hits the "POST" button in the PDF.

The code for the POST button is given:

PushbuttonField button1 = new PushbuttonField(
      stamper.getWriter(), new Rectangle(90, 660, 140, 690), "post");
button1.setText("PDFPOST");
button1.setBackgroundColor(new GrayColor(0.7f));
button1.setVisibility(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
PdfFormField submit1 = button1.getField();
submit1.setAction(PdfAction.createSubmitForm(
      "http://192.168.1.136:8085/LogFileExampleProject/PdfService", null,
       PdfAction.SUBMIT_PDF));
// add the button
stamper.addAnnotation(submit1, 1);

However, when the POST button is pushed after the user has filled out the form in the PDF, it makes a connection with the URI specified in createSubmitForm, but doesn't pass any of the TextField parameters. How can I go about doing this?

Upvotes: 0

Views: 1198

Answers (1)

Bruno Lowagie
Bruno Lowagie

Reputation: 77528

As documented, the option SUBMIT_PDF only works if you have Adobe Acrobat on the client side (this is one of the limitations imposed by Adobe on Adobe Reader). How do you want to receive the data? As an HTML query string (SUBMIT_HTML_FORMAT), as FDF (the default), or as XFDF (SUBMIT_XFDF)?

Upvotes: 1

Related Questions