Is it possible to create a RadioGroup with all unchecked items?

Product:
PDFTron
Product Version:
8.x

Is it possible to create a RadioGroup with all unchecked items?

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Yes we have new API’s that simplify form creation. See the following sample and APIs

In particular look for RadioButtonGroup

Note that this is a new API so you will need to update to the latest SDK version.

Thanks, I updated the latest SDK (9.2); in the RadioButtonGroup there is the Add method (rect, onstate) but I don’t understand how to set the onstate parameter to put all unchecked radios. I don’t find an example. I tried onstate = “0” and “X” and “” but in all cases all the item of the group are checked.

I did not specify before that I am using the linux version.

Great question, you will have to call the following after you call AddGroupButtonsToPage

// by default the first radio button is set. To reset that need to make the following two changes
radiobutton1.GetSDFObj().PutName("AS", "Off");
radio_group.GetField().GetSDFObj().Erase("V");

So taking our InteractiveForms sample the code would be something like this. Note I moved the generation of appearances to after the change above, since otherwise the appearance would reflect that the first radio button is set (stale appearance).

// RadioButton Widget Creation
// Create a radio button group and add three radio buttons in it. 
RadioButtonGroup radio_group = RadioButtonGroup.Create(doc, "RadioGroup");
RadioButtonWidget radiobutton1 = radio_group.Add(new Rect(140, 410, 190, 460));
radiobutton1.SetBackgroundColor(new ColorPt(1, 1, 0), 3);
RadioButtonWidget radiobutton2 = radio_group.Add(new Rect(310, 410, 360, 460));
radiobutton2.SetBackgroundColor(new ColorPt(0, 1, 0), 3);
RadioButtonWidget radiobutton3 = radio_group.Add(new Rect(480, 410, 530, 460));
radiobutton3.SetBackgroundColor(new ColorPt(0, 1, 1), 3);
radio_group.AddGroupButtonsToPage(blank_page);
// by default the first radio button is set. To reset that need to make the following two changes
radiobutton1.GetSDFObj().PutName("AS", "Off");
radio_group.GetField().GetSDFObj().Erase("V");
doc.RefreshFieldAppearances();