Using your provided code:
Document document = new Document();
Page page = document.getPages().add();
RadioButtonField rf = new RadioButtonField(page);
rf.setPartialName(“radio”);
Table table = new Table();
table.setColumnWidths(“100 20 100 20 100”);
Rectangle pageRect = page.getRect();
table.setTop((float) pageRect.getHeight()-200-15);
table.setLeft(170);
page.getParagraphs().add(table);
Row r1 = table.getRows().add();
Cell c1 = r1.getCells().add();
Cell c2 = r1.getCells().add();
Cell c3 = r1.getCells().add();
Cell c4 = r1.getCells().add();
Cell c5 = r1.getCells().add();
RadioButtonOptionField opt1 = new RadioButtonOptionField();
RadioButtonOptionField opt2 = new RadioButtonOptionField();
RadioButtonOptionField opt3 = new RadioButtonOptionField();
opt1.setOptionName(“Item1”);
opt2.setOptionName(“Item2”);
opt3.setOptionName(“Item3”);
opt1.setWidth(15);
opt1.setHeight(15);
opt2.setWidth(15);
opt2.setHeight(15);
opt3.setWidth(15);
opt3.setHeight(15);
rf.add(opt1);
rf.add(opt2);
rf.add(opt3);
document.getForm().add(rf, 1);
opt1.setBorder(new Border(opt1));
opt1.getBorder().setWidth(1);
opt1.getBorder().setStyle(BorderStyle.Solid);
opt1.getCharacteristics().setBorder(com.aspose.pdf.Color.getBlack());
opt1.getDefaultAppearance().setTextColor(java.awt.Color.RED);
opt1.setCaption(new TextFragment(“Item1”));
opt2.setBorder(new Border(opt2));
opt2.getBorder().setWidth(1);
opt2.getBorder().setStyle(BorderStyle.Solid);
opt2.getCharacteristics().setBorder(com.aspose.pdf.Color.getBlack());
opt2.getDefaultAppearance().setTextColor(java.awt.Color.RED);
opt2.setCaption(new TextFragment(“Item2”));
opt3.setBorder(new Border(opt3));
opt3.getBorder().setWidth(1);
opt3.getBorder().setStyle(BorderStyle.Solid);
opt3.getCharacteristics().setBorder(com.aspose.pdf.Color.getBlack());
opt3.getDefaultAppearance().setTextColor(java.awt.Color.RED);
opt3.setCaption(new TextFragment(“Item3”));
c1.getParagraphs().add(opt1);
c3.getParagraphs().add(opt2);
c5.getParagraphs().add(opt3);
document.save(dataDir + “PDFJAVA_39580_output.pdf”);
gives me a PDF with no visible radio button fields. If i hover my mouse above them, i get a rectangle showing there is something and when i click it, i get something like the exterior circle displayed.
screenshot_1.JPG (12.7 KB)
I was expecting something like the second screenshot:
screenshot_2.JPG (32.1 KB)
Can you advise me what I am doing wrong here? Using PDF 24.7.