Hello,
I’ve faced an issue with an option selection. I am trying to create new radio button with two options and select the first one. Here is my code:
using (Aspose.Pdf.Document document = new Aspose.Pdf.Document(@"C://sample.pdf"))
{
Table table = new Table
{
ColumnWidths = "120 120"
};
Row row = table.Rows.Add();
RadioButtonField radioButton = new RadioButtonField(document.Pages[1]);
foreach (string optionName in new List<string> { "option1", "option2" })
{
RadioButtonOptionField option = new RadioButtonOptionField
{
OptionName = optionName,
Height = 70,
Width = 70,
Caption = new TextFragment(optionName)
};
radioButton.Add(option);
Cell cell = row.Cells.Add();
cell.Paragraphs.Add(option);
}
radioButton.Options[1].Selected = true;
radioButton.Selected = 1;
document.Form.Add(radioButton);
document.Pages[1].Paragraphs.Add(table);
document.Save(@"C://result.pdf");
}
Can you please help me with this issue? Am I doing something wrong?
files.zip (37.5 KB)
image.png (29.3 KB)
Regards,
Alex