Radiobuttons alignment - Aspose PDF

Is there a way to set Horizontal alignment for radiobuttons. In the forums I see to use FormEditor, but in this case wondering is there any option to set radio buttions horizontally instead of vertical alignment. Below is the partial code. Tried aligment for each parent table,row,radiobutton but nothing seems to work.

Aspose.Pdf.Table table = new Aspose.Pdf.Table();
table.ColumnAdjustment = ColumnAdjustment.AutoFitToWindow;

       // table.ColumnWidths = "120 120 120";
        page.Paragraphs.Add(table);
        table.ColumnWidths = "33% 33% 33%";

        TextFragment textFragment = new TextFragment("Main Header");

        Row rowheader = table.Rows.Add();
        Cell celleader1 = rowheader.Cells.Add();
        celleader1.ColSpan = 3;
        celleader1.BackgroundColor = Color.LightGray;

        //Cell celleader2 = rowheader.Cells.Add();
        //Cell celleader3 = rowheader.Cells.Add();
        celleader1.Paragraphs.Add(textFragment);

        Row r1 = table.Rows.Add();
        Cell c1 = r1.Cells.Add();
        c1.BackgroundColor = Color.Aqua;
        Cell c2 = r1.Cells.Add();
        c2.BackgroundColor = Color.Green;
        c2.ColSpan = 2;
        //Cell c3 = r1.Cells.Add();
        //c3.BackgroundColor = Color.Blue;

        RadioButtonField rf = new RadioButtonField(page);
        rf.IsInLineParagraph = true;
       // rf.Name = "rfName";
        rf.PartialName = "rfPartialName";
        
        doc.Form.Add(rf,1);

        RadioButtonOptionField opt1 = new RadioButtonOptionField();
        RadioButtonOptionField opt2 = new RadioButtonOptionField();
        RadioButtonOptionField opt3 = new RadioButtonOptionField();

        opt1.OptionName = "optionItem1.1";
        opt1.Name = "optionItem1Name";
       // opt1.PartialName = "optionItem1PartialName";


        opt2.OptionName = "optionItem2.2";
        opt2.Name = "optionItem2Name";
        //opt2.PartialName = "optionItem2PartialName";

        opt3.OptionName = "optionItem3.3";
        opt3.Name = "optionItem3Name";
        //opt3.PartialName = "optionItem4PartialName";
        

        opt1.Width = 15;
        opt1.Height = 15;
        opt2.Width = 15;
        opt2.Height = 15;
        opt3.Width = 15;
        opt3.Height = 15;

        rf.Add(opt1);
        rf.Add(opt2);
        rf.Add(opt3);
        rf.HorizontalAlignment = HorizontalAlignment.Left;
        

        
        opt1.Border = new Border(opt1);
        opt1.Border.Width = 1;
        opt1.Border.Style = BorderStyle.Solid;
        opt1.Characteristics.Border = System.Drawing.Color.Black;
        opt1.DefaultAppearance.TextColor = System.Drawing.Color.Black;
        opt1.Caption = new TextFragment("Pavan");
        opt2.Border = new Border(opt1);

@dotnet14

Thanks for your inquiry.

We have tried following code snippet to align right a radio button in table cell but did not get much success, so have logged an issue as PDFNET-43611 in our issue tracking system.

Document pdfDocument = new Document();
Page pdfPage = pdfDocument.Pages.Add();

Table table = new Table();
table.Margin = new MarginInfo { Left = 20, Right = 20, Top = 10, Bottom = 0 };
pdfPage.Paragraphs.Add(table);
table.ColumnWidths = "100 100";
RadioButtonField rf = new RadioButtonField(pdfPage);
rf.PartialName = "GroupedRadio";

RadioButtonOptionField option = new RadioButtonOptionField();

option.OptionName = "Yes";
option.Width = 15;
option.Height = 15;
option.Caption = new TextFragment("Yes");
rf.MappingName = "1";
rf.Add(option);

RadioButtonOptionField option2 = new RadioButtonOptionField();

option2.OptionName = "No";
option2.Width = 15;
option2.Height = 15;
option2.Caption = new TextFragment("No");
rf.MappingName = "2";
rf.HorizontalAlignment = HorizontalAlignment.Right;
rf.Add(option2);

rf.Selected = 2;

rf.Add(option);
rf.Add(option2);

pdfDocument.Form.Add(rf, pdfPage.Number);

Row row = table.Rows.Add();
Cell cellYesField = row.Cells.Add();
cellYesField.Border = new BorderInfo(BorderSide.All, 1f, Color.Black);
cellYesField.Paragraphs.Add(option);
Cell cellNoField = row.Cells.Add();
cellNoField.Border = new BorderInfo(BorderSide.All, 1f, Color.Black);
cellNoField.Alignment = HorizontalAlignment.Right;
cellNoField.Paragraphs.Add(option2);

pdfDocument.Save(dataDir + "RadioButtonAlignment.pdf");

RadioButtonAlignment.pdf (58.1 KB)

We will further look into the logged issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.