Radio buttons in PDF script

P

Paul E. Schoen

I was trying to see how radio buttons worked in a PDF form. I started with
the incorrect assumption that they worked just like they do in Delphi,
although I was not sure how to create a group. But I was surprised to find
that the boolean property checked is read-only, and one must write 'On' or
'Off' to set the visual indication and the resulting 'checked' property.

I have two radio buttons initialized to rb1 and rb2, and I have set both of
them to be unchecked initially. I also have three more radio buttons each
named 'RadioButton3', and they operate in a mutually exclusive manner as
expected.

Finally, I created a button which runs the following script:

app.alert( 'rb1.checked: ' + rb1.checked ); // true, although it should
not be
app.alert( 'rb1.value: ' + rb1.value ); // 'Off' as it should be, and as
indicated
app.alert( 'rb2.checked: ' + rb2.checked ); // false. as expected
app.alert( 'rb2.value: ' + rb2.value ); // 'Off', as expected
app.alert( 'rb2.value: ' + rb2.value ); // '4'

var rb3 = this.getField("RadioButton3");
app.alert( 'rb3.length: ' + rb3.length ); // undefined
app.alert( 'rb3.checked: ' + rb3.checked ); // undefined
app.alert( 'rb3[0].checked: ' +rb3[0].checked ); // error
// Method or property not allowed for this field type: => field.alignment
for(i=0; i<rb3.length; i++)
app.alert( 'rb3[' + i + '] checked: ' + rb3.checked);

When I exported the data in the form I found this:

/Fields [<</T (Text1)
/V ()
<</T (CheckBox1) /V (Yes)
<</T (RadioButton1) /V ()
<</T (RadioButton2) /V (Yes)
<</T (RadioButton3) /V (4)
]

It seems that the value of RadioButton3 (4) indicates that the third
instance of RadioButton3 is checked. I realize these anomalies may be
implementation-specific or even a bug in Nitro PDF. In fact, after
reloading the document, I got undefined as the checked property for rb1 and
rb2, which was corrected once I actually clicked them.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top