Class PdfChoiceFormField


public class PdfChoiceFormField extends PdfFormField
An AcroForm field type representing any type of choice field. Choice fields are to be represented by a viewer as a list box or a combo box.
  • Field Details

    • FF_COMBO

      public static final int FF_COMBO
      If true, the field is a combo box. If false, the field is a list box.
    • FF_EDIT

      public static final int FF_EDIT
      If true, the combo box shall include an editable text box as well as a drop-down list. If false, it shall include only a drop-down list. This flag shall be used only if the Combo flag is true.
    • FF_SORT

      public static final int FF_SORT
      If true, the field's option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers.
    • FF_MULTI_SELECT

      public static final int FF_MULTI_SELECT
      If true, more than one of the field's option items may be selected simultaneously. If false, at most one item shall be selected.
    • FF_DO_NOT_SPELL_CHECK

      public static final int FF_DO_NOT_SPELL_CHECK
      If true, text entered in the field shall be spell-checked.
    • FF_COMMIT_ON_SEL_CHANGE

      public static final int FF_COMMIT_ON_SEL_CHANGE
      If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).
  • Constructor Details

  • Method Details

    • getFormType

      public PdfName getFormType()
      Returns Ch, the form type for choice form fields.
      Overrides:
      getFormType in class PdfFormField
      Returns:
      the form type, as a PdfName
    • setTopIndex

      public PdfChoiceFormField setTopIndex (int index)
      Sets the index of the first visible option in a scrollable list.
      Parameters:
      index - the index of the first option
      Returns:
      current PdfChoiceFormField
    • getTopIndex

      public PdfNumber getTopIndex()
      Gets the current index of the first option in a scrollable list.
      Returns:
      the index of the first option, as a PdfNumber
    • setIndices

      public PdfChoiceFormField setIndices (PdfArray indices)
      Sets the selected items in the field.
      Parameters:
      indices - a sorted array of indices representing selected items in the field
      Returns:
      current PdfChoiceFormField
    • setListSelected

      public PdfChoiceFormField setListSelected (String[] optionValues)
      Highlights the options. If this method is used for Combo box, the first value in input array will be the field value
      Parameters:
      optionValues - Array of options to be highlighted
      Returns:
      current PdfChoiceFormField
    • setListSelected

      public PdfChoiceFormField setListSelected (String[] optionValues, boolean generateAppearance)
      Highlights the options and generates field appearance if needed. If this method is used for Combo box, the first value in input array will be the field value
      Parameters:
      optionValues - Array of options to be highlighted
      generateAppearance - if false, appearance won't be regenerated
      Returns:
      current PdfChoiceFormField
    • setListSelected

      public PdfChoiceFormField setListSelected (int[] optionNumbers)
      Highlights the options. If this method is used for Combo box, the first value in input array will be the field value
      Parameters:
      optionNumbers - The option numbers
      Returns:
      The edited PdfChoiceFormField
    • getIndices

      public PdfArray getIndices()
      Gets the currently selected items in the field
      Returns:
      a sorted array of indices representing the currently selected items in the field
    • setCombo

      public PdfChoiceFormField setCombo (boolean combo)
      If true, the field is a combo box; if false, the field is a list box.
      Parameters:
      combo - whether or not the field should be a combo box
      Returns:
      current PdfChoiceFormField
    • isCombo

      public boolean isCombo()
      If true, the field is a combo box; if false, the field is a list box.
      Returns:
      whether or not the field is now a combo box.
    • setEdit

      public PdfChoiceFormField setEdit (boolean edit)
      If true, the combo box shall include an editable text box as well as a drop-down list; if false, it shall include only a drop-down list. This flag shall be used only if the Combo flag is true.
      Parameters:
      edit - whether or not to add an editable text box
      Returns:
      current PdfChoiceFormField
    • isEdit

      public boolean isEdit()
      If true, the combo box shall include an editable text box as well as a drop-down list; if false, it shall include only a drop-down list. This flag shall be used only if the Combo flag is true.
      Returns:
      whether or not there is currently an editable text box
    • setSort

      public PdfChoiceFormField setSort (boolean sort)
      If true, the field's option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers.
      Parameters:
      sort - whether or not to sort the items
      Returns:
      current PdfChoiceFormField
    • isSort

      public boolean isSort()
      If true, the field's option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers.
      Returns:
      whether or not the items are currently sorted
    • setMultiSelect

      public PdfChoiceFormField setMultiSelect (boolean multiSelect)
      If true, more than one of the field's option items may be selected simultaneously; if false, at most one item shall be selected.
      Parameters:
      multiSelect - whether or not to allow multiple selection
      Returns:
      current PdfChoiceFormField
    • isMultiSelect

      public boolean isMultiSelect()
      If true, more than one of the field's option items may be selected simultaneously; if false, at most one item shall be selected.
      Returns:
      whether or not multiple selection is currently allowed
    • setSpellCheck

      public PdfChoiceFormField setSpellCheck (boolean spellCheck)
      If true, text entered in the field shall be spell-checked.
      Parameters:
      spellCheck - whether or not to require the PDF viewer to perform a spell check
      Returns:
      current PdfChoiceFormField
    • isSpellCheck

      public boolean isSpellCheck()
      If true, text entered in the field shall be spell-checked..
      Returns:
      whether or not PDF viewer must perform a spell check
    • setCommitOnSelChange

      public PdfChoiceFormField setCommitOnSelChange (boolean commitOnSelChange)
      If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).
      Parameters:
      commitOnSelChange - whether or not to save changes immediately
      Returns:
      current PdfChoiceFormField
    • isCommitOnSelChange

      public boolean isCommitOnSelChange()
      If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).
      Returns:
      whether or not to save changes immediately