1

I'm trying to read pdf form. I managed to get normal textbox value by doing this.
Code

PdfReader reader = new PdfReader(RESULT1);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT2));
AcroFields form = stamper.getAcroFields();
String name = form.getField("Text1");//Check Box 1
System.out.println("Name "+name);

How do I get check box value. Please advice.

chinna_82
  • 6,353
  • 17
  • 79
  • 134
  • 1
    There should be no difference between getting the value of a normal text box and the value of a check box. Both values are to be retrieved with the `getField()` method. Have you tried? Are you sure you're using the correct name of the check box? – Bruno Lowagie Dec 13 '13 at 10:33

1 Answers1

1

As Bruno said in his comment, you should be able to get the value of a check box with the code you posted. You can use form.getAppearanceStates(NAME_OF_CHECKBOX) to get a String array of possible values. For a check box, these should be Off and Yes.

rhens
  • 4,791
  • 3
  • 22
  • 38
  • Yeah...there was issue in the field name. My field name has spaces.. Eg: "Check Box 1". Once i moved the space it works fine. To add on on your answer. Check box returns `Yes` and null. – chinna_82 Dec 18 '13 at 04:27