The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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.