I am trying to modify an existing PDF with iText. My code currently edits text fields nicely, but I cant get it to tick or un-tick a checkbox.
PdfReader reader = new PdfReader(INPUTFILE);
int n = reader.getNumberOfPages();
PdfStamper filledOutForm = new PdfStamper(reader, new FileOutputStream("WrittenForm.pdf"));
AcroFields fields = filledOutForm.getAcroFields();
//not working
fields.setField("checkbox", "On");
//working
fields.setField("textfield1", "infinite road");
fields.setField("textfield2", "jayboy");
filledOutForm.close();
Any ideas?
SOLVED:
String states[] = fields.getAppearanceStates("checkbox");
//prints array values - returns 'yes, no'
System.out.println(Arrays.toString(states));