Radio Button Choice is Preselected

When I am using radio buttons, the first one listed in my XML is automatically preselected when I generate the PDF. This should not happen, but there should be a way for me to programmatically select a radio button.

Let me know how long this will take to fix/include.

Thanks!

Dan

Hi,

Thank you for considering Aspose.

Yes, there is a way programmatically. Please refer to the following code.

[C#]

Pdf pdf1 = new Pdf();

Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.Text text1 = new Text();

sec1.Paragraphs.Add(text1);

text1.Segments.Add("This is a test for inline radiobutton: ");

text1.InlineRadioButtonFieldName = “inlineradio”;

text1.InlineRadioButtonCheckedIndex = 1;

Segment seg1 = text1.Segments.Add();

Aspose.Pdf.RadioButton radio1 = new Aspose.Pdf.RadioButton();

seg1.InlineParagraph = radio1;

Segment seg11 = text1.Segments.Add("radio1 ");

Segment seg2 = text1.Segments.Add();

Aspose.Pdf.RadioButton radio2 = new Aspose.Pdf.RadioButton();

radio2.ButtonHeight = radio2.ButtonWidth = 15;

seg2.InlineParagraph = radio2;

Segment seg22 = text1.Segments.Add("radio2 ");

Segment seg3 = text1.Segments.Add();

Aspose.Pdf.RadioButton radio3 = new Aspose.Pdf.RadioButton();

seg3.InlineParagraph = radio3;

Segment seg33 = text1.Segments.Add("radio3 ");

pdf1.Save(“D:/AsposeTest/InlineRadioButtonExample.pdf”);

[XML]

FormField Group2: FontSize=10, InlineRadioButtonCheckedIndex=“3”

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

Alright, but if I create the objects in XML, how do I reference them from code? I tried the following but it did not work.

[XML]








[VB]

'Tell the radio button not to preselect anything
myPdf.GetObjectById("text1").InlineRadioButtonCheckedIndex = -1

---------------------

Please let me know how I can do this.

Thanks!

Dan

Hi,

Please check the following code after binding the sample XML add these lines of code to get to the text objects.

foreach (Section sec in pdf.Sections)

{

foreach (Paragraph para in sec.Paragraphs)

{

if (para is Text)

{

Text t = para as Text;

//Can get the Text ID

foreach (Segment seg in t.Segments)

{

//Can get the Segment ID

}

}

}

}

pdf.Save("");

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

This does not answer my question. I want to set the "InlineRadioButtonCheckedId" property of the Text object surrounding my radio buttons. This works just fine if all of the radio buttons are created in code, but not when they are defined in the XML.

Please fix this.

Thanks!

Dan

This has been replied at https://forum.aspose.com/t/132058#76819.