## com.lowagie.text.pdf
Class TextField

    java.lang.Object
      com.lowagie.text.pdf.BaseField
          com.lowagie.text.pdf.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 (psoares@consiste.pt)

Field Summary
`private String[]` `choiceExports` Holds value of property choiceExports.
`private String[]` `choices` Holds value of property choices.
`private int` `choiceSelection` Holds value of property choiceSelection.
`private String` `defaultText` Holds value of property defaultText.
`private float` `extraMarginLeft`
`private float` `extraMarginTop`
`private int` `topFirst`

Fields inherited from class com.lowagie.text.pdf.BaseField

`alignment, backgroundColor, BORDER_WIDTH_MEDIUM, BORDER_WIDTH_THICK, BORDER_WIDTH_THIN, borderColor, borderStyle, borderWidth, box, COMB, DO_NOT_SCROLL, DO_NOT_SPELL_CHECK, EDIT, fieldName, FILE_SELECTION, font, fontSize, HIDDEN, HIDDEN_BUT_PRINTABLE, maxCharacterLength, MULTILINE, options, PASSWORD, READ_ONLY, REQUIRED, rotation, text, textColor, visibility, VISIBLE, VISIBLE_BUT_DOES_NOT_PRINT, writer`

Constructor Summary
`TextField(PdfWriter writer, Rectangle box, String fieldName)` Creates a new `TextField`.

Method Summary
`PdfAppearance` `getAppearance()` Gets the appearance for this TextField.
`String[]` `getChoiceExports()` Gets the export values in list/combo fields.
`protected PdfFormField` `getChoiceField(boolean isList)`
`String[]` `getChoices()` Gets the choices to be presented to the user in list/combo fields.
`int` `getChoiceSelection()` Gets the zero based index of the selected item.
`PdfFormField` `getComboField()` Gets a new combo field.
`String` `getDefaultText()` Gets the default text.
`(package private) PdfAppearance` `getListAppearance()`
`PdfFormField` `getListField()` Gets a new list field.
`PdfFormField` `getTextField()` Gets a new text field.
`(package private) int` `getTopFirst()`
`void` `setChoiceExports(String[] choiceExports)` Sets the export values in list/combo fields.
`void` `setChoices(String[] choices)` Sets the choices to be presented to the user in list/combo fields.
`void` `setChoiceSelection(int choiceSelection)` Sets the zero based index of the selected item.
`void` `setDefaultText(String defaultText)` Sets the default text.
`void` `setExtraMargin(float extraMarginLeft, float extraMarginTop)` Sets extra margins in text fields to better mimic the Acrobat layout.

Methods inherited from class com.lowagie.text.pdf.BaseField

`breakLines, getAlignment, getBackgroundColor, getBorderAppearance, getBorderColor, getBorderStyle, getBorderWidth, getBox, getFieldName, getFont, getFontSize, getHardBreaks, getMaxCharacterLength, getOptions, getRealFont, getRotation, getText, getTextColor, getVisibility, getWriter, moveFields, setAlignment, setBackgroundColor, setBorderColor, setBorderStyle, setBorderWidth, setBox, setFieldName, setFont, setFontSize, setMaxCharacterLength, setOptions, setRotation, setRotationFromPage, setText, setTextColor, setVisibility, setWriter, trimRight`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### defaultText

    private String defaultText

  Holds value of property defaultText.

### choices

    private String[] choices

  Holds value of property choices.

### choiceExports

    private String[] choiceExports

  Holds value of property choiceExports.

### choiceSelection

    private int choiceSelection

  Holds value of property choiceSelection.

### topFirst

    private int topFirst

### extraMarginLeft

    private float extraMarginLeft

### extraMarginTop

    private float extraMarginTop

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

### getAppearance

    public PdfAppearance getAppearance()
                                throws IOException,
                                       DocumentException

  Gets the appearance for this TextField.

  Returns:
    the appearance object for this TextField
  Throws:
    `IOException`
    `DocumentException`

### getListAppearance

    PdfAppearance getListAppearance()
                              throws IOException,
                                     DocumentException

  Throws:
    `IOException`
    `DocumentException`

### getTextField

    public PdfFormField getTextField()
                              throws IOException,
                                     DocumentException

  Gets a new text field.

  Returns:
    a new text field
  Throws:
    `IOException` - on error
    `DocumentException` - on error

### getComboField

    public PdfFormField getComboField()
                               throws IOException,
                                      DocumentException

  Gets a new combo field.

  Returns:
    a new combo field
  Throws:
    `IOException` - on error
    `DocumentException` - on error

### getListField

    public PdfFormField getListField()
                              throws IOException,
                                     DocumentException

  Gets a new list field.

  Returns:
    a new list field
  Throws:
    `IOException` - on error
    `DocumentException` - on error

### getChoiceField

    protected PdfFormField getChoiceField(boolean isList)
                                   throws IOException,
                                          DocumentException

  Throws:
    `IOException`
    `DocumentException`

### 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

### 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

### getTopFirst

    int getTopFirst()

### setExtraMargin

    public void setExtraMargin(float extraMarginLeft,
                               float extraMarginTop)

  Sets extra margins in text fields to better mimic the Acrobat layout.

  Parameters:
    `extraMarginLeft` - the extra marging left
    `extraMarginTop` - the extra margin top