Free Support Forum - aspose.com

Aspose RadioButton default select while creation of pdf of document

Hi,
i have code to set default value to display radiobutton is selected
value is setting to the button but that is not highlighting.

          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");

added radio button inside the cell so its not displaying.

Even i had same issue, any help on this would be highly appreciated.

@indra0606

Thank you for contacting support.

We would like to request you to create a self-contained, compilable code snippet that can be used to reproduce the issue in our environment, because shared code snippet includes some undefined fields and is incomplete. Please also share source and generated PDF files so that we may proceed to help you out. Before sharing requested data, please ensure using Aspose.PDF for Java 18.4 in your environment.

@Namala_Suresh

We have replied you in the thread created by you. Kindly follow up in respective thread.

@Farhan.Raza

i have updated above the code. you can reproduce the issue in your environment.

@indra0606

We have been able to reproduce the issue in our environment. A ticket with ID PDFJAVA-37761 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.