The radio button are not viewing

When I run the code below the radio button fields are not in standard mode. Its a blue field above the
fields and they appear when I push them. How can I style the radio buttons look like a normal radio button? I have attached a sample on how it appears in a pdf. levUT1.pdf (27.3 KB)

public static void addingRadioButton(Document pdfDocument, int page, double llx, double lly, double urx, double ury) {
// add a page to PDF file
pdfDocument.getPages().add();

        // instantiate RadioButtonField object with page number as argument
        RadioButtonField radio = new RadioButtonField(pdfDocument.getPages().get_Item(page));
        RadioButtonOptionField opt1 = new RadioButtonOptionField();
        RadioButtonOptionField opt2 = new RadioButtonOptionField();
        // add first radio button option and also specify its origin using Rectangle
        // object
        
        radio.addOption("Ja", new Rectangle(llx, lly, urx, ury));
        radio.addOption("Nei", new Rectangle(llx+80, lly, urx, ury));
        
        pdfDocument.getForm().add(radio);
        // save the PDF file
        pdfDocument.save("/tmp/RadioButtonField.pdf");

    }

@ron.inputdata.no

We are afraid that we could not clearly understand the issue. Can you please share a sample expected output as well for our reference? We will further proceed to assist you accordingly.

This is my code which should create 2 radiobuttons labeled with “ja” and “nei”.
But only the buttons are viewing, and they are market with blue color.
I provide you my code and mye files. I convert my lev.docx to lev.pdf who is the inputfile and levUT1.pdf is the output.

lev.pdf (44.4 KB)
levUT1.pdf (75.6 KB)
lev.docx (25.3 KB)

 private static String docx="/tmp/lev.docx";
 private static String startfile="/tmp/lev.pdf";
	public static void main(String[] args) throws IOException {
            try {            
                com.aspose.words.License licenseWords = new com.aspose.words.License();
                com.aspose.pdf.License licensePdf = new com.aspose.pdf.License(); 

                String fileTotal="/Users/ronwaatsveen/Aspose.Total.Java.lic";
                licenseWords.setLicense(fileTotal); 
                licensePdf.setLicense(fileTotal);
                editFields();
            } catch (Exception ex) {
                ex.printStackTrace();            
            }
	}
 public static String replaceText(Document asposedoc, String code, String innfile, String outfile,  String fieldtype) {
            String retfile=null;
            try {
                TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(code.trim());
                asposedoc.getPages().accept(textFragmentAbsorber);
                TextFragmentCollection textFragmentCollection2 = textFragmentAbsorber.getTextFragments();

                for (TextFragment textFragment : textFragmentCollection2) {
                    int page = textFragment.getPage().getNumber();
                    Rectangle rectangle = textFragment.getRectangle();
                    textFragment.setText("");
                    float llx= (float) rectangle.getLLX();
                    float lly= (float) rectangle.getLLY();
                    float urx= (float) rectangle.getURX();
                    float ury= (float) rectangle.getURY();
                    addRadioButtonFieldInPDFDocument(asposedoc, page, llx, lly, urx, ury);
                    asposedoc.save(outfile);
                    retfile=outfile;
                }
            } catch(Exception e) {
                e.printStackTrace();
            }
            return retfile;
        }
public static void addRadioButtonFieldInPDFDocument(Document document, int p, double llx, double lly, double urx, double ury) {
		// instantiate Document object
                //int p=1;
		//Document document = new Document("/tmp/lev.pdf");
		RadioButtonField rf = new RadioButtonField(document.getPages().get_Item(p));
                rf.setPartialName("yesorno");

                RadioButtonOptionField opt1 = new RadioButtonOptionField(document.getPages().get_Item(p), new Rectangle(llx, lly, urx, ury));
                RadioButtonOptionField opt2 = new RadioButtonOptionField(document.getPages().get_Item(p), new Rectangle(llx+80, lly, urx, ury));


                opt1.setOptionName("Ja");
                opt2.setOptionName("Nei");
               
                //opt2.setStyle(1);
                
                opt1.setWidth(15);
                opt1.setHeight(15);
                opt2.setWidth(15);
                opt2.setHeight(15);

                opt1.setBorder(new Border(opt1));
                opt1.getBorder().setWidth(1);
                opt1.getBorder().setStyle(BorderStyle.Solid);
                opt1.getCharacteristics().setBorder(Color.BLACK);
                opt1.getDefaultAppearance().setTextColor(Color.BLACK);
                opt1.setCaption(new TextFragment("Item1")); // opt1.setPartialName("Item1");

                opt2.setBorder(new Border(opt2));
                opt2.getBorder().setWidth(1);
                opt2.getBorder().setStyle(BorderStyle.Solid);
                opt2.getCharacteristics().setBorder(Color.BLACK);
                opt2.getDefaultAppearance().setTextColor(Color.BLACK);
                opt2.setCaption(new TextFragment("Item2")); // opt2.setPartialName("Item2");

                rf.add(opt1);
                rf.add(opt2);

                document.getForm().add(rf, 1);
		// save the PDF file
		//document.save("/tmp/RadioButtonSample.pdf");
	}

@ron.inputdata.no

We are checking it and will get back to you shortly.

@ron.inputdata.no

The radio buttons captions can be shown using below approach:

page.getParagraphs().add(opt1);
page.getParagraphs().add(opt2);

However, the position of the radio buttons will be changed in the output PDF. When adding RadioButtonOptionField like a paragraph of the page, the rectangle of RadioButtonOptionField does not set the position of the radio button.

In this case position of the radio button can be set using a Table generator. Please check the code snippet given in another thread where a similar issue was discussed.