vibhor (5) [Avatar] Offline
#1
Hello

can you please tell me how to check/uncheck the radio buttons in pdf using iText. Please see the code below i am trying to do :

============================
PdfReader reader = new PdfReader(PDF_TEMPLATE);
// filling in the form
PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream(PDF_RESULT));
AcroFields form1 = stamp1.getAcroFields();
form1.setField("radioButtonName", "On");


stamp1.close();

==========================
But when i open the result pdf, the radiobutton is yet unchecked or vic-e-versa.
Am i missing something ? is this right way to check/uncheck a checkbox ?

I need this to be working asap.
Can you help ?

-Thanks
blowagie (284) [Avatar] Offline
#2
Re: Problem Regarding Radio Button
You are using the correct method (see also page 505; that example WORKS!!!);
but looking at this code snippet, I can see two possible errors:
form1.setField("radioButtonName", "On");

Is "radioButtonName" the correct name of the field?
Maybe you need "myform.radioButton".
Please use the code shown on p503 to find out if "radioButtonName" is indeed an existing field.

Suppose a button field with name "radioButtonName" actually exists, are you sure "On" is a possible value? It could as well be "true" or "1" or something else.
Please use the code shown on p504 to find out the possible values.