Find RadioButton selected index or value

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

Hi Ken,

I have reproduced this problem at my end and logged it as PDFKITNET-14113 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once the issue is resolved.

We’re sorry for the inconvenience.
Regards,

Hi Ken,

Our team has looked into this issue and I would like to inform you that the file you shared earlier contains only radio button with the appearance attributes, but doesn’t contain option values. Since the options are not defined for this button, we would only be able to return the values ‘On’ or ‘Off’ for the button instances, but we won’t know which button’s value is ‘On’ or ‘Off’. Is it something you want? If not, please specify the button option values explicitly for all the three radio button instances.

Please share your further thoughts, so we could proceed with this issue.
Regards,

Thanks for the response.

I would like to be able to specify the button option values when the pdf is created, and then retrieve the selected value. I have tried to set the radio button values, but I have been unsuccessful. Could you provide me with an example of how I could modify the code I used to create the form to explicitly set the button option values?

Hi Ken,

We’re looking into this matter and you’ll be updated with the status shortly.

We’re sorry for the inconvenience.
Regards,

Hello Ken,

Sorry for replying you late.

I've tested the scenario and I'm able to notice that there is no such mechanism to specify the RadioButton values. For the sake of correction, I've logged this requirement under New Features list as PDFNET-14292 over our Issue tracking system. We will look into the details of this matter and will keep you updated with the status of correction.

Please be patient and spare us little time. Your cooperation and comprehension is greatly appreciated in this regard.

We apologize for your inconvenience.

Is there currently a way to get the selected index of the field and change it?

Hi Ken,

Yes, this is possible. You can get all the option button values using GetButtonOptionValues method. If you want to get currently selected value you can use GetButtonOptionCurrentValue. In order to change the current index you can use FillField method.


I hope this helps. If you have any further questions, please do let us know.
Regards,

The issues you have found earlier (filed as 14292) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.