Hello,
I am using Aspose.Pdf to create a pdf containing radio buttons, and then using Aspose.Pdf.Kit to manipulate the form.
After loading the pdf into a Aspose.Pdf.Kit.Form, I am unable to get the selected index or value of the radio button.
I have tried Form.GetField("ButtonName"); and it returns a blank string.
Form.GetButtonOptionCurrentValue("ButtonName"); Throws a PdfKitException "Unable to find selected value for the specified field!".
I am also unable to use Form.FillField("ButtonName", int); to change the selected index.
How can I get the index or value of the selected radio button?
Sample code to create the PDF:
Pdf ThisPdf = new Pdf();
MarginInfo marginInfo = new MarginInfo();
marginInfo.Top = 28;
marginInfo.Bottom = 28;
marginInfo.Left = 28;
marginInfo.Right = 28;
Section MainSection = ThisPdf.Sections.Add();
MainSection.PageInfo.Margin = marginInfo;
//add table for layout of radio buttons
Aspose.Pdf.Table RadioTable = new Aspose.Pdf.Table();
MainSection.Paragraphs.Add(RadioTable);
// add rows and cells to hold the radio button text
Row ThisRow;
Cell ThisCell;
ThisRow = RadioTable.Rows.Add();
ThisCell = ThisRow.Cells.Add("Red");
ThisCell.Padding.Left = 30;
ThisCell.Paragraphs[0].ID = "RedOption";
ThisRow = RadioTable.Rows.Add();
ThisCell = ThisRow.Cells.Add("Yellow");
ThisCell.Padding.Left = 30;
ThisCell.Paragraphs[0].ID = "YellowOption";
ThisRow = RadioTable.Rows.Add();
ThisCell = ThisRow.Cells.Add("Green");
ThisCell.Padding.Left = 30;
ThisCell.Paragraphs[0].ID = "GreenOption";
// Make the Radio control to hold the radio items
FormField ThisRadioControl = new FormField();
ThisRadioControl.FormFieldType = FormFieldType.RadioButton;
ThisRadioControl.FieldName = "Color";
ThisRadioControl.RadioButtonCheckedIndex = 0;
// Add Radio Buttons
Aspose.Pdf.RadioButton bt1;
bt1 = ThisRadioControl.RadioButtons.Add();
bt1.ButtonHeight = 12;
bt1.ButtonWidth = 12;
bt1.PositioningType = PositioningType.ParagraphRelative;
bt1.ReferenceParagraphID = "RedOption";
bt1.IsInList = true;
bt1.Left = -20;
bt1.Top = 0;
bt1 = ThisRadioControl.RadioButtons.Add();
bt1.ButtonHeight = 12;
bt1.ButtonWidth = 12;
bt1.PositioningType = PositioningType.ParagraphRelative;
bt1.ReferenceParagraphID = "YellowOption";
bt1.IsInList = true;
bt1.Left = -20;
bt1.Top = 0;
bt1 = ThisRadioControl.RadioButtons.Add();
bt1.ButtonHeight = 12;
bt1.ButtonWidth = 12;
bt1.PositioningType = PositioningType.ParagraphRelative;
bt1.ReferenceParagraphID = "GreenOption";
bt1.IsInList = true;
bt1.Left = -20;
bt1.Top = 0;
MainSection.Paragraphs.Add(ThisRadioControl);
I have also attached the sample pdf.
Thanks for any help