I am trying to learn how to manipulate PDFs with the iText library. I am able to retrieve the value or state of a checkbox.
For example:
public static void manipulatePdf(String src, String dest) throws DocumentException, IOException {
PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
AcroFields fields = stamper.getAcroFields();
String[] checkbox = fields.getAppearanceStates("cb1"); //cb1 is the name of the checkbox in my test PDF
for(int i = 0; i < checkbox.length; i++) {
System.out.println(checkbox[i]);
}
System.out.println(fields.getField("cb1"));
Output is: Yes Off Yes
My question here is how to check if a radio button is checked. I could not find any solutions for this.
I tried the same code like:
System.out.println(fields.getField("Choice1")); //Choice1 is the name of the first radio button in my first group "group1"
Aucun commentaire:
Enregistrer un commentaire