We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Split radio button to next line

Hi ,
i have 4 radiobuttons which i need to display two radio button each in single line with in table
like 1 2
3 4

is there any method to set ??

@indra0606,

Please update us which Aspose component are using at your end. This information will help us to answer your inquiry accordingly.

Document doc = new Document();
Table tabler = new Table();
Page page = doc.getPages().add();
tabler.setColumnWidths(“50 80”);
Row r1 = tabler.getRows().add();
Cell c2 = r1.getCells().add();
Cell c3 = r1.getCells().add();
RadioButtonField rf = new RadioButtonField(doc);
rf.setPartialName(“radio”);
page.getDocument().getForm().add(rf, 1);
RadioButtonOptionField opt1 = new RadioButtonOptionField(page, new Rectangle(100,280,180,295));
RadioButtonOptionField opt2 = new RadioButtonOptionField(page, new Rectangle(200,380,280,395));
opt1.setOptionName(“1”);
opt2.setOptionName(“2”);
opt1.setWidth(11);
opt1.setHeight(11);
opt2.setWidth(11);
opt2.setHeight(11);
opt1.setCaption(new TextFragment(“Yes”));
rf.setMappingName(“mapingName”);
opt1.setMappingName(“mapingName”);
opt2.setCaption(new TextFragment(“No”));
opt2.setMappingName(“mapingName”);
rf.add(opt1);
rf.add(opt2);
opt1.setBorder(new Border(opt1));
opt1.getBorder().setWidth(1);
opt1.getBorder().setStyle(BorderStyle.Solid);
opt1.getDefaultAppearance().setTextColor(java.awt.Color.RED);
opt2.setBorder(new Border(opt2));
opt2.getBorder().setWidth(1);
opt2.getBorder().setStyle(BorderStyle.Solid);
opt2.getDefaultAppearance().setTextColor(java.awt.Color.RED);
rf.setSelected(rf.getOptions().get(“1”).getIndex());
c2.getParagraphs().add(opt1);
c3.getParagraphs().add(opt2);
page.getParagraphs().add(tabler);
doc.save(dataDir + “in.pdf”);

this code i’m using i need to display each radio button in single line.
like 1
2

@indra0606

Thank you for contacting support.

We would like to request you to use below code snippet in your environment and then share your kind feedback with us. It adds two radio buttons on two separate lines as per your requirements.

        Document doc = new Document();
        Table tabler = new Table();
        Page page = doc.Pages.Add();
        tabler.ColumnWidths = ("50 80");
        Row r1 = tabler.Rows.Add();
        Row r2 = tabler.Rows.Add();
        Cell c2 = r1.Cells.Add();
        Cell c3 = r2.Cells.Add();
        RadioButtonField rf = new RadioButtonField(doc);
        rf.PartialName= "radio";
        doc.Form.Add(rf, 1);
        RadioButtonOptionField opt1 = new RadioButtonOptionField(page, new Rectangle(100,280,180,295));
        RadioButtonOptionField opt2 = new RadioButtonOptionField(page, new Rectangle(200,380,280,395));
        opt1.OptionName = "1";
        opt2.OptionName = "2";
        opt1.Width  = 11;
        opt1.Height = 11;
        opt2.Width = 11;
        opt2.Height = 11;
        opt1.Caption = (new TextFragment("Yes"));
        rf.MappingName = "mapingName";
        opt1.MappingName = "mapingName";
        opt2.Caption = (new TextFragment("No"));
        opt2.MappingName = "mapingName";
        rf.Add(opt1);
        rf.Add(opt2);
        opt1.Border = (new Border(opt1));
        opt1.Border.Width = (1);
        opt1.Border.Style = (BorderStyle.Solid);
        opt1.DefaultAppearance.TextColor = (System.Drawing.Color.Red);
        opt2.Border = (new Border(opt2));
        opt2.Border.Width = (1);
        opt2.Border.Style = (BorderStyle.Solid);
        opt2.DefaultAppearance.TextColor = (System.Drawing.Color.Red);
        rf.Selected = rf.Options["1"].Index;//.getOptions().get("1").getIndex());
        c2.Paragraphs.Add(opt1);
        c3.Paragraphs.Add(opt2);
        //Create MarginInfo object and set its bottom and top margins
        MarginInfo margin = new MarginInfo();
        margin.Top = 1f;
        margin.Bottom = 1f;
        //Set the default cell padding to the MarginInfo object
        tabler.DefaultCellPadding = margin;
        page.Paragraphs.Add(tabler);
        doc.Save(dataDir + "Test_18.5.pdf");

We hope this will be helpful. Please feel free to contact us if you need any further assistance.