// Create a pdf file stream FileOutputStream outputStream = null; try { outputStream = new FileOutputStream("FormControlMapPdfFormFieldBasicUsage.pdf"); } catch (FileNotFoundException e) { e.printStackTrace(); } // Create a new workbook Workbook workbook = new Workbook(); IWorksheet ws = workbook.getWorksheets().get("Sheet1"); ws.getRange("$B$2:$C$2").setValue(new Object[][] { {"Excel Form Control", "Mapped to form field"} }); ws.getRange("$B$4").setValue("Dropdown (Combo box) "); ws.getRange("$B$6").setValue("List box"); ws.getRange("$B$11").setValue("Option button"); ws.getRange("$B$14").setValue("Check box"); ws.getRange("$B$2:$C$2").getInterior().setThemeColor(ThemeColor.Light2); ws.getRange("$B$4").setVerticalAlignment(VerticalAlignment.Center); ws.getRange("$B$14").setVerticalAlignment(VerticalAlignment.Center); ws.getRange("$4:$4,$14:$14").setRowHeight(18.6d); ws.getRange("$11:$11").setRowHeight(15.6d); ws.getRange("$12:$12").setRowHeight(26.4d); ws.getRange("$B:$B").setColumnWidthInPixel(162d); ws.getRange("$C:$C").setColumnWidthInPixel(214d); IDropDown ctl1 = ws.getControls().addDropDown(177.3, 45.6, 141, 16.79); ctl1.getItems().add(new DropDownItem("Item 1")); ctl1.getItems().add(new DropDownItem("Item 2")); ctl1.getItems().add(new DropDownItem("Item 3")); ctl1.setSelectedIndex(0); IListBox ctl2 = ws.getControls().addListBox(177.9, 80.39, 140.4, 55.8); ctl2.getItems().add(new ListBoxItem("Item 1")); ctl2.getItems().add(new ListBoxItem("Item 2")); ctl2.getItems().add(new ListBoxItem("Item 3")); ctl2.setSelectedIndex(0); IOptionButton ctl3 = ws.getControls().addOptionButton(176.7, 152.4, 71.4, 17.39); ctl3.setText("Option Button 1"); IOptionButton ctl4 = ws.getControls().addOptionButton(177.3, 175.2, 71.39, 16.80); ctl4.setText("Option Button 2"); ICheckBox ctl5 = ws.getControls().addCheckBox(177.9, 211.79, 58.19, 16.80); ctl5.setText("Check Box 1"); PdfSaveOptions tempVar = new PdfSaveOptions(); tempVar.setFormFields(true); workbook.save(outputStream, tempVar); // Close the file stream try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); }