Radio buttons are displaying as circles and caption is missing

Hi,

When I am creating Radio buttons on the PDF file using the below code, It is adding Radio buttons but the radio option value is not displaying. It is showing radio buttons as circles and caption is missing. Could anybody please help me in fixing this.

Implementation:

Document doc = new Document(“filename.pdf”));
RadioButtonField radio = new RadioButtonField(doc.Pages[1]);
radio.PartialName = txtString[0];
FloatingBox fb = new FloatingBox();
fb.Left = (float)(shapeX * 0.05f);
fb.Top = (float)(shapeY * 0.83f);
doc.Pages[wholeData.shapes[i].p].Paragraphs.Add(fb);
//fb.Width = 50.0f;
for (int loopStrArr = 1; loopStrArr < txtString.Length; loopStrArr++)
{
//int row = (loopStrArr - 1) * 15;
//float positionX = shapeX + row;
//double positionY = yaxis + row;
RadioButtonOptionField opt1 = new RadioButtonOptionField();
opt1.OptionName = txtString[loopStrArr].Replace(" ", string.Empty);
opt1.Width = Convert.ToInt32(wholeData.shapes[i].s);
opt1.Height = Convert.ToInt32(wholeData.shapes[i].s);
radio.Add(opt1);
opt1.Caption = new Aspose.Pdf.Text.TextFragment(txtString[loopStrArr]);
opt1.Border = new Aspose.Pdf.InteractiveFeatures.Annotations.Border(opt1);
opt1.Border.Width = 1;
opt1.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;
opt1.Characteristics.Border = System.Drawing.Color.Yellow;
opt1.DefaultAppearance.TextColor = System.Drawing.Color.Red;
//opt1.SetPosition(new Point((double)positionX, (double)positionY));
fb.Paragraphs.Add(opt1);
}
//radio.SetPosition(new Point((double)shapeX, (double)yaxis));
doc.Form.Add(radio);

Regards,
Nithin Eate

Hi Nithin,

Thanks for contacting support.

I have tried to run your code snippet but was unable to execute it as there were some undefined/missing objects in it. Though I have tried to add radio button inside floating box using Aspose.Pdf for .NET 17.4.0, by following code snippet and did not observe any issue.

Document doc = new Document();
doc.Pages.Add();

RadioButtonField radio = new RadioButtonField(doc.Pages[1]);
radio.PartialName = "radio";

FloatingBox fb = new FloatingBox();
fb.Left = (float)(100);
fb.Top = (float)(50);
doc.Pages[1].Paragraphs.Add(fb);

RadioButtonOptionField opt1 = new RadioButtonOptionField();
opt1.OptionName = "Option1";
opt1.Width = 20;
opt1.Height = 10;
opt1.Caption = new TextFragment("Option 1");

RadioButtonOptionField opt2 = new RadioButtonOptionField();
opt2.OptionName = "Option2";
opt2.Width = 20;
opt2.Height = 10;
opt2.Caption = new TextFragment("Option 2");
radio.Add(opt1);
radio.Add(opt2);
doc.Form.Add(radio);
fb.Paragraphs.Add(opt1);
fb.Paragraphs.Add(opt2);
doc.Save(dataDir + "radiobuttoncaption_out.pdf");

For your reference, an output generated by above code snippet, is also attached. We would really appreciate if you please share a working code snippet along with sample input document, so that we can try to replicate issue in our environment and address it accordingly.

Best Regards,