// Create a pdf file stream FileOutputStream outputStream = null; try { outputStream = new FileOutputStream("FormControlMapPdfFormField.pdf"); } catch (FileNotFoundException e) { e.printStackTrace(); } // Create a new workbook Workbook workbook = new Workbook(); IWorksheet ws = workbook.getWorksheets().get("Sheet1"); ws.getRange("$A$1").setValue("Skirmish: Game Settings"); ws.getRange("$D$3:$E$7").setValue("Initial funds"); ws.getRange("$G$3:$H$7").setValue("Map preview"); ws.getRange("$A$9:$A$11").setValue(new Object[][] { {"Player"}, {"You"}, {"AI Player 1"} }); ws.getRange("$B$9:$C$10").setValue(new Object[][] { {"AI Level", null}, {"-", null} }); ws.getRange("$D$9:$E$9").setValue(new Object[][] { {"Side", "Color"} }); ws.getRange("$F$9:$G$11").setValue(new Object[][] { {"Team", null}, {"-", null}, {"-", null} }); ws.getRange("$H$9").setValue("Ready"); IFont a1Fnt = ws.getRange("$A$1").getFont(); a1Fnt.setThemeColor(ThemeColor.Accent4); a1Fnt.setName("游ゴシック"); a1Fnt.setSize(16d); IFont a2Fnt = ws.getRange("$A$2:$F$2").getFont(); a2Fnt.setName("游ゴシック"); a2Fnt.setSize(16d); IFont b1Fnt = ws.getRange("$B$1:$H$1,$A$9:$A$11,$B$9:$H$9").getFont(); b1Fnt.setThemeColor(ThemeColor.Accent4); b1Fnt.setName("游ゴシック"); IInterior a1Back = ws.getRange("$A$1:$H$1,$A$9:$A$11,$B$9:$H$9").getInterior(); a1Back.setThemeColor(ThemeColor.Dark1); a1Back.setPattern(Pattern.Solid); a1Back.setPatternColor(Color.GetBlack()); a1Back.setPatternColorIndex(-4105); IInterior a3Back = ws.getRange("$A$3:$B$7,$D$3:$E$7,$G$3:$H$7").getInterior(); a3Back.setColor(Color.FromArgb(0xFFDDEBF7)); IBorders a1Border = ws.getRange("$A$1:$G$1,$A$3,$D$3,$G$3,$A$9").getBorders(); a1Border.get(BordersIndex.EdgeLeft).setColorIndex(57); a1Border.get(BordersIndex.EdgeLeft).setLineStyle(BorderLineStyle.Thin); a1Border.get(BordersIndex.EdgeTop).setColorIndex(57); a1Border.get(BordersIndex.EdgeTop).setLineStyle(BorderLineStyle.Thin); IBorders a4Border = ws.getRange("$A$4:$A$6,$D$4:$D$6,$G$4:$G$6").getBorders(); a4Border.get(BordersIndex.EdgeLeft).setColorIndex(57); a4Border.get(BordersIndex.EdgeLeft).setLineStyle(BorderLineStyle.Thin); IBorders a7Border = ws.getRange("$A$7,$D$7,$G$7,$A$11").getBorders(); a7Border.get(BordersIndex.EdgeBottom).setColorIndex(57); a7Border.get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thin); a7Border.get(BordersIndex.EdgeLeft).setColorIndex(57); a7Border.get(BordersIndex.EdgeLeft).setLineStyle(BorderLineStyle.Thin); IBorders a10Border = ws.getRange("$A$10").getBorders(); a10Border.get(BordersIndex.EdgeBottom).setThemeColor(ThemeColor.Accent4); a10Border.get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thin); a10Border.get(BordersIndex.EdgeLeft).setColorIndex(57); a10Border.get(BordersIndex.EdgeLeft).setLineStyle(BorderLineStyle.Thin); a10Border.get(BordersIndex.EdgeTop).setThemeColor(ThemeColor.Accent4); a10Border.get(BordersIndex.EdgeTop).setLineStyle(BorderLineStyle.Thin); IBorders b3Border = ws.getRange("$B$3,$E$3,$H$3,$H$9").getBorders(); b3Border.get(BordersIndex.EdgeRight).setColorIndex(57); b3Border.get(BordersIndex.EdgeRight).setLineStyle(BorderLineStyle.Thin); b3Border.get(BordersIndex.EdgeTop).setColorIndex(57); b3Border.get(BordersIndex.EdgeTop).setLineStyle(BorderLineStyle.Thin); IBorders b4Border = ws.getRange("$B$4:$B$6,$E$4:$E$6,$H$4:$H$6,$H$10").getBorders(); b4Border.get(BordersIndex.EdgeRight).setColorIndex(57); b4Border.get(BordersIndex.EdgeRight).setLineStyle(BorderLineStyle.Thin); IBorders b7Border = ws.getRange("$B$7,$E$7,$H$7,$H$11").getBorders(); b7Border.get(BordersIndex.EdgeBottom).setColorIndex(57); b7Border.get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thin); b7Border.get(BordersIndex.EdgeRight).setColorIndex(57); b7Border.get(BordersIndex.EdgeRight).setLineStyle(BorderLineStyle.Thin); IBorders h1Border = ws.getRange("$H$1,$B$9:$G$9").getBorders(); h1Border.get(BordersIndex.EdgeTop).setColorIndex(57); h1Border.get(BordersIndex.EdgeTop).setLineStyle(BorderLineStyle.Thin); IBorders b11Border = ws.getRange("$B$11:$G$11").getBorders(); b11Border.get(BordersIndex.EdgeBottom).setColorIndex(57); b11Border.get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thin); IRange a1 = ws.getRange("$A$1"); a1.setHorizontalAlignment(HorizontalAlignment.Left); a1.setAddIndent(false); IRange a2 = ws.getRange("$A$2:$F$2"); a2.setVerticalAlignment(VerticalAlignment.Center); a2.setAddIndent(false); IRange b1 = ws.getRange("$B$1:$F$1,$G$1:$H$2,$A$3:$B$7,$A$9,$B$9:$C$11,$D$9:$E$9,$F$9:$G$11,$H$9"); b1.setHorizontalAlignment(HorizontalAlignment.Center); b1.setAddIndent(false); IRange a10 = ws.getRange("$A$10:$A$11"); a10.setHorizontalAlignment(HorizontalAlignment.Center); a10.setVerticalAlignment(VerticalAlignment.Center); a10.setAddIndent(false); IRange d3 = ws.getRange("$D$3:$E$7,$G$3:$H$7"); d3.setHorizontalAlignment(HorizontalAlignment.Center); d3.setVerticalAlignment(VerticalAlignment.Top); d3.setAddIndent(false); ws.getRange("$D$3:$E$7").merge(); ws.getRange("$A$3:$B$7").merge(); ws.getRange("$F$10:$G$10").merge(); ws.getRange("$F$11:$G$11").merge(); ws.getRange("$B$10:$C$10").merge(); ws.getRange("$B$11:$C$11").merge(); ws.getRange("$B$9:$C$9").merge(); ws.getRange("$G$3:$H$7").merge(); ws.getRange("$G$1:$H$1").merge(); ws.getRange("$F$9:$G$9").merge(); ws.getRange("$1:$1").setRowHeight(24.6d); ws.getRange("$2:$2").setRowHeight(6d); ws.getRange("$10:$10").setRowHeight(19.8d); ws.getRange("$11:$11").setRowHeight(22.8d); ws.getRange("$A:$A").setColumnWidthInPixel(111d); ws.getRange("$B:$B").setColumnWidthInPixel(95d); ws.getRange("$C:$C,$F:$F").setColumnWidthInPixel(11d); ws.getRange("$D:$D").setColumnWidthInPixel(105d); ws.getRange("$E:$E").setColumnWidthInPixel(83d); IDropDown ctl1 = ws.getControls().addDropDown(179.55, 46.80, 102.63, 21.00); ctl1.getItems().add(new DropDownItem("10000")); ctl1.getItems().add(new DropDownItem("15000")); ctl1.getItems().add(new DropDownItem("20000")); ctl1.getItems().add(new DropDownItem("30000")); ctl1.setSelectedIndex(0); ICheckBox ctl2 = ws.getControls().addCheckBox(175.95, 70.20, 99.15, 17.40); ctl2.setIsChecked(true); ctl2.setText("Generate crates"); IDropDown ctl3 = ws.getControls().addDropDown(85.65, 157.80, 72.45, 16.80); ctl3.getItems().add(new DropDownItem("Easy")); ctl3.getItems().add(new DropDownItem("Normal")); ctl3.getItems().add(new DropDownItem("Hard")); ctl3.getItems().add(new DropDownItem("Brutal")); ctl3.setSelectedIndex(2); ICheckBox ctl4 = ws.getControls().addCheckBox(175.95, 87.60, 99.15, 16.80); ctl4.setIsChecked(true); ctl4.setText("Tiberium grows"); IDropDown ctl5 = ws.getControls().addDropDown(165.75, 138.00, 66.60, 15.60); ctl5.getItems().add(new DropDownItem("GDI")); ctl5.getItems().add(new DropDownItem("Nod")); ctl5.getItems().add(new DropDownItem("Scrin")); ctl5.setSelectedIndex(0); IDropDown ctl6 = ws.getControls().addDropDown(165.75, 157.80, 66.00, 16.80); ctl6.getItems().add(new DropDownItem("GDI")); ctl6.getItems().add(new DropDownItem("Nod")); ctl6.getItems().add(new DropDownItem("Scrin")); ctl6.setSelectedIndex(1); ICheckBox ctl7 = ws.getControls().addCheckBox(380.40, 136.80, 19.20, 18.00); ctl7.setText(""); ICheckBox ctl8 = ws.getControls().addCheckBox(380.40, 157.80, 19.20, 18.00); ctl8.setIsChecked(true); ctl8.setText(""); ; IDropDown ctl9 = ws.getControls().addDropDown(243.90, 138.60, 51.00, 14.40); ctl9.getItems().add(new DropDownItem("Random")); ctl9.getItems().add(new DropDownItem("Red")); ctl9.getItems().add(new DropDownItem("Green")); ctl9.getItems().add(new DropDownItem("Blue")); ctl9.getItems().add(new DropDownItem("Yellow")); ctl9.getItems().add(new DropDownItem("Purple")); ctl9.setSelectedIndex(0); IDropDown ctl10 = ws.getControls().addDropDown(243.90, 159.00, 51.00, 15.60); ctl10.getItems().add(new DropDownItem("Random")); ctl10.getItems().add(new DropDownItem("Red")); ctl10.getItems().add(new DropDownItem("Green")); ctl10.getItems().add(new DropDownItem("Blue")); ctl10.getItems().add(new DropDownItem("Yellow")); ctl10.getItems().add(new DropDownItem("Purple")); ctl10.setSelectedIndex(0); IListBox ctl11 = ws.getControls().addListBox(3.60, 34.20, 140.25, 67.80); ctl11.getItems().add(new ListBoxItem("Infinite Isle (2)")); ctl11.getItems().add(new ListBoxItem("Temple Prime (2)")); ctl11.getItems().add(new ListBoxItem("Industrial Strength (2)")); ctl11.getItems().add(new ListBoxItem("Hot Spring (2-4)")); ctl11.getItems().add(new ListBoxItem("Motherland (2-6)")); ctl11.setSelectedIndex(0); IShape shp1 = ws.getShapes().addShape(AutoShapeType.Oval, 371.56, 49.40, 24.57, 31.17); shp1.getFill().getColor().setRGB(Color.FromArgb(0xFFFFDB96)); shp1.getLine().getColor().setRGB(Color.FromArgb(0xFFFFC000)); shp1.getLine().setWeight(0.5); IShape shp2 = ws.getShapes().addShape(AutoShapeType.Oval, 330.44, 68.04, 26.36, 31.81); shp2.getFill().getColor().setRGB(Color.FromArgb(0xFFFFDB96)); shp2.getLine().getColor().setRGB(Color.FromArgb(0xFFFFC000)); shp2.getLine().setWeight(0.5); IShape shp3 = ws.getShapes().addShape(AutoShapeType.Rectangle, 338.40, 67.06, 54.75, 15.07); shp3.getFill().getColor().setRGB(Color.FromArgb(0xFFFFC000)); shp3.getLine().getColor().setRGB(Color.GetWhite()); shp3.getLine().setWeight(1.5); shp3.setRotation(36.5); IOptionButton ctl12 = ws.getControls().addOptionButton(334.42, 79.07, 14.92, 17.15); ctl12.setIsChecked(true); ctl12.setText("1"); IOptionButton ctl13 = ws.getControls().addOptionButton(378.22, 51.41, 14.92, 17.15); ctl13.setText("2"); PdfSaveOptions tempVar = new PdfSaveOptions(); tempVar.setFormFields(true); workbook.save(outputStream, tempVar); // Close the file stream try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); }