An interactive form, sometimes referred to as an AcroForm, is a collection of fields for gathering information interactively from the user. A PDF document may contain any number of fields, appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document.
Interactive forms support the following field types:
- Button fields represent interactive controls on the screen that a user can manipulate with the mouse. They include push buttons, check boxes, and radio buttons.
- Text fields are boxes or spaces in which the user can enter text from the keyboard.
- Check Box fields are interactive controls that a user can toggle between.
- Radio Button fields are a set of related toggles that at most one can be selected.
- Choice fields contain several text items; only one value may be selected at a time. They include scrollable list boxes and combo boxes.
- Signature fields are boxes or spaces in which a digital signature can be placed.
Form field content can be validated for formatting or for auto filling values with JavaScript using AnnotationReaderEvents. Please refer to the JavaScript topic for more information.
This example shows how to create a Button and add it to the page.
[Java]
Button button = new Button( "Button Name", 50, 50, 100, 50 );
button.setAction(new JavaScriptAction( "app.alert('Hello');" ));
button.setBackgroundColor(RgbColor.getAliceBlue());
button.setBehavior(Behavior.createPush( "downLabel", "rolloverLabel" ));
button.setBorderColor(RgbColor.getBlueViolet());
button.setBorderStyle(BorderStyle.BEVELED);
button.setLabel("Push");
button.setTextColor(RgbColor.getDarkGreen());
button.setToolTip("Click");
This example shows how to create an Check Box and add it to the page.
[Java]
CheckBox checkBox = new CheckBox( "Check Box Name", 5, 7, 50, 50 );
checkBox.setDefaultChecked(true);
checkBox.setToolTip("Check it");
This example shows how to create a Combo Box and add it to the page.
[Java]
ComboBox comboBox = new ComboBox( "Combo Box Name", 50, 75, 150, 25 );
comboBox.addItem( "One",true );
comboBox.addItem( "Two" );
comboBox.addItem( "Three" );
comboBox.setBackgroundColor(RgbColor.getAliceBlue());
comboBox.setBorderColor(RgbColor.getDarkMagenta());
comboBox.setDefaultChoice("One");
comboBox.setEditable(true);
comboBox.setToolTip("Select");
This example shows how to create a List Box and add it to the page.
[Java]
ListBox listBox = new ListBox( "List Box Name", 5, 2, 100, 150 );
listBox.addItem( "One",true );
listBox.addItem( "Two" );
listBox.addItem( "Three" );
listBox.setBackgroundColor(RgbColor.getAliceBlue());
listBox.setBorderColor(RgbColor.getDarkMagenta());
listBox.setBorderStyle(BorderStyle.DASHED);
listBox.setDefaultChoice("One");
listBox.setMultiselect(true);
listBox.setToolTip("Select");
This example shows how to create a Radio Button and add it to the page.
[Java]
RadioButton radio1 = new RadioButton( "Radio Button Name", 50, 25, 100, 75 );
radio1.setDefaultChecked(true);
radio2.setExportValue("abc");
radio1.setToolTip("first");
RadioButton radio2 = new RadioButton( "Radio Button Name", 50, 140, 100, 75 );
radio2.setExportValue("def");
radio2.setToolTip("second");
RadioButton radio3 = new RadioButton( "Radio Button Name", 50, 250, 100, 75 );
radio3.setExportValue("ghi");
radio3.setToolTip("third");
This example shows how to create a Text Field and add it to the page.
[Java]
TextField textField = new TextField( "Text Field Name", 50, 75, 150, 100 );
textField.setTextAlign(Align.CENTER);
textField.setBackgroundColor(RgbColor.getAliceBlue());
textField.setBorderColor(RgbColor.getDeepPink());
textField.setFont(Font.getTimesItalic());
textField.setFontSize(16.0f);
textField.setTextColor(RgbColor.getBrown());
textField.setDefaultValue("ceTe Software");
textField.setMultiLine(true);
textField.setToolTip("Text");
This example shows how to create a Signature and add it to the page.
[Java]
Signature signature = new Signature("MySigField", 10, 10, 300, 100);
Font font = new OpenTypeFont("[PhysicalPath]/times.ttf");
signature.setFont((FormFont)font);
signature.getFullPanel().setImage("[PhysicalPath]/MyImage.gif");
signature.getLeftPanel().setTextColor(RgbColor.getRed());