Class TextField


  • public class TextField
    extends BaseField
    Supports text, combo and list fields generating the correct appearances. All the option in the Acrobat GUI are supported in an easy to use API.
    Author:
    Paulo Soares
    • Constructor Detail

      • TextField

        public TextField​(PdfWriter writer,
                         Rectangle box,
                         String fieldName)
        Creates a new TextField.
        Parameters:
        writer - the document PdfWriter
        box - the field location and dimensions
        fieldName - the field name. If null only the widget keys will be included in the field allowing it to be used as a kid field.
    • Method Detail

      • removeCRLF

        public static String removeCRLF​(String text)
        Removes CRLF from a String.
        Parameters:
        text -
        Returns:
        String
        Since:
        2.1.5
      • obfuscatePassword

        public static String obfuscatePassword​(String text)
        Obfuscates a password String. Every character is replaced by an asterisk (*).
        Parameters:
        text -
        Returns:
        String
        Since:
        2.1.5
      • getDefaultText

        public String getDefaultText()
        Gets the default text.
        Returns:
        the default text
      • setDefaultText

        public void setDefaultText​(String defaultText)
        Sets the default text. It is only meaningful for text fields.
        Parameters:
        defaultText - the default text
      • getChoices

        public String[] getChoices()
        Gets the choices to be presented to the user in list/combo fields.
        Returns:
        the choices to be presented to the user
      • setChoices

        public void setChoices​(String[] choices)
        Sets the choices to be presented to the user in list/combo fields.
        Parameters:
        choices - the choices to be presented to the user
      • getChoiceExports

        public String[] getChoiceExports()
        Gets the export values in list/combo fields.
        Returns:
        the export values in list/combo fields
      • setChoiceExports

        public void setChoiceExports​(String[] choiceExports)
        Sets the export values in list/combo fields. If this array is null then the choice values will also be used as the export values.
        Parameters:
        choiceExports - the export values in list/combo fields
      • getChoiceSelection

        public int getChoiceSelection()
        Gets the zero based index of the selected item.
        Returns:
        the zero based index of the selected item
      • getChoiceSelections

        public ArrayList<Integer> getChoiceSelections()
        Gets the selected items.
        Returns:
        the selected items
        Since:
        5.0.1
      • setVisibleTopChoice

        public void setVisibleTopChoice​(int visibleTopChoice)
        Sets the top visible choice for lists;
        Parameters:
        visibleTopChoice - index of the first visible item (zero-based array)
        Since:
        5.5.3
      • getVisibleTopChoice

        public int getVisibleTopChoice()
        Returns the index of the top visible choice of a list. Default is -1.
        Returns:
        the index of the top visible choice
      • setChoiceSelection

        public void setChoiceSelection​(int choiceSelection)
        Sets the zero based index of the selected item.
        Parameters:
        choiceSelection - the zero based index of the selected item
      • addChoiceSelection

        public void addChoiceSelection​(int selection)
        Adds another (or a first I suppose) selection to a MULTISELECT list. This doesn't do anything unless this.options & MUTLISELECT != 0
        Parameters:
        selection - new selection
      • setChoiceSelections

        public void setChoiceSelections​(ArrayList<Integer> selections)
        Replaces the existing selections with the param. If this field isn't a MULTISELECT list, all but the first element will be removed.
        Parameters:
        selections - new selections. If null, it clear()s the underlying ArrayList.
      • setExtraMargin

        public void setExtraMargin​(float extraMarginLeft,
                                   float extraMarginTop)
        Sets extra margins in text fields to better mimic the Acrobat layout.
        Parameters:
        extraMarginLeft - the extra margin left
        extraMarginTop - the extra margin top
      • getSubstitutionFonts

        public ArrayList<BaseFont> getSubstitutionFonts()
        Gets the list of substitution fonts. The list is composed of BaseFont and can be null. The fonts in this list will be used if the original font doesn't contain the needed glyphs.
        Returns:
        the list
      • setSubstitutionFonts

        public void setSubstitutionFonts​(ArrayList<BaseFont> substitutionFonts)
        Sets a list of substitution fonts. The list is composed of BaseFont and can also be null. The fonts in this list will be used if the original font doesn't contain the needed glyphs.
        Parameters:
        substitutionFonts - the list
      • getExtensionFont

        public BaseFont getExtensionFont()
        Gets the extensionFont. This font will be searched before the substitution fonts. It may be null.
        Returns:
        the extensionFont
      • setExtensionFont

        public void setExtensionFont​(BaseFont extensionFont)
        Sets the extensionFont. This font will be searched before the substitution fonts. It may be null.
        Parameters:
        extensionFont - New value of property extensionFont.