|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lowagie.text.pdf.TextField
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.
Field Summary | |
protected int |
alignment
|
protected Color |
backgroundColor
|
static float |
BORDER_WIDTH_MEDIUM
A medium border with 2 point width. |
static float |
BORDER_WIDTH_THICK
A thick border with 3 point width. |
static float |
BORDER_WIDTH_THIN
A thin border with 1 point width. |
protected Color |
borderColor
|
protected int |
borderStyle
|
protected float |
borderWidth
|
protected Rectangle |
box
|
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. |
static int |
DO_NOT_SCROLL
The field will not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than will fit within its annotation rectangle. |
static int |
DO_NOT_SPELL_CHECK
The text entered in the field will not be spell-checked. |
static int |
EDIT
If set the combo box includes an editable text box as well as a drop list; if clear, it includes only a drop list. |
private String |
fieldName
Holds value of property fieldName. |
static int |
FILE_SELECTION
The text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field. |
protected BaseFont |
font
|
protected float |
fontSize
|
static int |
HIDDEN
The field is hidden. |
static int |
HIDDEN_BUT_PRINTABLE
The field is hidden but is printable. |
private int |
maxCharacterLength
Holds value of property maxCharacterLength. |
static int |
MULTILINE
The field may contain multiple lines of text. |
private int |
options
Holds value of property options. |
static int |
PASSWORD
The field is intended for entering a secure password that should not be echoed visibly to the screen. |
static int |
READ_ONLY
The user may not change the value of the field. |
static int |
REQUIRED
The field must have a value at the time it is exported by a submit-form action. |
protected int |
rotation
Holds value of property rotation. |
protected String |
text
|
protected Color |
textColor
|
private int |
topFirst
|
private int |
visibility
Holds value of property visibility. |
static int |
VISIBLE
The field is visible. |
static int |
VISIBLE_BUT_DOES_NOT_PRINT
The field is visible but does not print. |
protected PdfWriter |
writer
|
Constructor Summary | |
TextField(PdfWriter writer,
Rectangle box,
String fieldName)
Creates a new TextField . |
Method Summary | |
protected static ArrayList |
breakLines(ArrayList breaks,
BaseFont font,
float fontSize,
float width)
|
private void |
drawBottomFrame(PdfAppearance app)
|
private void |
drawTopFrame(PdfAppearance app)
|
int |
getAlignment()
Gets the text horizontal alignment. |
PdfAppearance |
getAppearance()
|
Color |
getBackgroundColor()
Gets the background color. |
protected PdfAppearance |
getBorderAppearance()
|
Color |
getBorderColor()
Gets the border color. |
int |
getBorderStyle()
Gets the border style. |
float |
getBorderWidth()
Gets the border width in points. |
Rectangle |
getBox()
Gets the field dimension and position. |
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. |
String |
getFieldName()
Gets the field name. |
BaseFont |
getFont()
Gets the text font. |
float |
getFontSize()
Gets the font size. |
protected static ArrayList |
getHardBreaks(String text)
|
(package private) PdfAppearance |
getListAppearance()
|
PdfFormField |
getListField()
Gets a new list field. |
int |
getMaxCharacterLength()
Gets the maximum length of the field’s text, in characters. |
int |
getOptions()
Gets the option flags. |
protected BaseFont |
getRealFont()
|
int |
getRotation()
Gets the field rotation. |
String |
getText()
Gets the text. |
Color |
getTextColor()
Gets the text color. |
PdfFormField |
getTextField()
Gets a new text field. |
(package private) int |
getTopFirst()
|
int |
getVisibility()
Gets the field visibility flag. |
void |
setAlignment(int alignment)
Sets the text horizontal alignment. |
void |
setBackgroundColor(Color backgroundColor)
Sets the background color. |
void |
setBorderColor(Color borderColor)
Sets the border color. |
void |
setBorderStyle(int borderStyle)
Sets the border style. |
void |
setBorderWidth(float borderWidth)
Sets the border width in points. |
void |
setBox(Rectangle box)
Sets the field dimension and position. |
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 |
setFieldName(String fieldName)
Sets the field name. |
void |
setFont(BaseFont font)
Sets the text font. |
void |
setFontSize(float fontSize)
Sets the font size. |
void |
setMaxCharacterLength(int maxCharacterLength)
Sets the maximum length of the field’s text, in characters. |
void |
setOptions(int options)
Sets the option flags. |
void |
setRotation(int rotation)
Sets the field rotation. |
void |
setRotationFromPage(Rectangle page)
Convenience method to set the field rotation the same as the page rotation. |
void |
setText(String text)
Sets the text for text fields. |
void |
setTextColor(Color textColor)
Sets the text color. |
void |
setVisibility(int visibility)
Sets the field visibility flag. |
protected static void |
trimRight(StringBuffer buf)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final float BORDER_WIDTH_THIN
public static final float BORDER_WIDTH_MEDIUM
public static final float BORDER_WIDTH_THICK
public static final int VISIBLE
public static final int HIDDEN
public static final int VISIBLE_BUT_DOES_NOT_PRINT
public static final int HIDDEN_BUT_PRINTABLE
public static final int READ_ONLY
public static final int REQUIRED
public static final int MULTILINE
public static final int DO_NOT_SCROLL
public static final int PASSWORD
public static final int FILE_SELECTION
public static final int DO_NOT_SPELL_CHECK
EDIT
flag set.
public static final int EDIT
protected float borderWidth
protected int borderStyle
protected Color borderColor
protected Color backgroundColor
protected Color textColor
protected BaseFont font
protected float fontSize
protected int alignment
protected PdfWriter writer
protected String text
protected Rectangle box
protected int rotation
private int visibility
private String fieldName
private String defaultText
private int options
private int maxCharacterLength
private String[] choices
private String[] choiceExports
private int choiceSelection
private int topFirst
Constructor Detail |
public TextField(PdfWriter writer, Rectangle box, String fieldName)
TextField
.
writer
- the document PdfWriter
box
- the field location and dimensionsfieldName
- the field nameMethod Detail |
protected BaseFont getRealFont() throws IOException, DocumentException
IOException
DocumentException
protected PdfAppearance getBorderAppearance() throws IOException, DocumentException
IOException
DocumentException
public PdfAppearance getAppearance() throws IOException, DocumentException
IOException
DocumentException
PdfAppearance getListAppearance() throws IOException, DocumentException
IOException
DocumentException
protected static ArrayList getHardBreaks(String text)
protected static void trimRight(StringBuffer buf)
protected static ArrayList breakLines(ArrayList breaks, BaseFont font, float fontSize, float width)
public PdfFormField getTextField() throws IOException, DocumentException
IOException
- on error
DocumentException
- on errorpublic PdfFormField getComboField() throws IOException, DocumentException
IOException
- on error
DocumentException
- on errorpublic PdfFormField getListField() throws IOException, DocumentException
IOException
- on error
DocumentException
- on errorprotected PdfFormField getChoiceField(boolean isList) throws IOException, DocumentException
IOException
DocumentException
private void drawTopFrame(PdfAppearance app)
private void drawBottomFrame(PdfAppearance app)
public float getBorderWidth()
public void setBorderWidth(float borderWidth)
null
.
borderWidth
- the border width in pointspublic int getBorderStyle()
public void setBorderStyle(int borderStyle)
PdfBorderDictionary
and can be STYLE_SOLID
, STYLE_DASHED
,
STYLE_BEVELED
, STYLE_INSET
and
STYLE_UNDERLINE
.
borderStyle
- the border stylepublic Color getBorderColor()
public void setBorderColor(Color borderColor)
null
to remove
the border.
borderColor
- the border colorpublic Color getBackgroundColor()
public void setBackgroundColor(Color backgroundColor)
null
for
transparent background.
backgroundColor
- the background colorpublic Color getTextColor()
public void setTextColor(Color textColor)
null
the color used
will be black.
textColor
- the text colorpublic BaseFont getFont()
public void setFont(BaseFont font)
null
then Helvetica
will be used.
font
- the text fontpublic float getFontSize()
public void setFontSize(float fontSize)
fontSize
- the font sizepublic int getAlignment()
public void setAlignment(int alignment)
Element.ALIGN_LEFT
,
Element.ALIGN_CENTER
and Element.ALIGN_RIGHT
.
alignment
- the text horizontal alignmentpublic String getText()
public void setText(String text)
text
- the textpublic Rectangle getBox()
public void setBox(Rectangle box)
box
- the field dimension and positionpublic int getRotation()
public void setRotation(int rotation)
rotation
- the field rotationpublic void setRotationFromPage(Rectangle page)
page
- the pagepublic int getVisibility()
public void setVisibility(int visibility)
VISIBLE
, HIDDEN
, VISIBLE_BUT_DOES_NOT_PRINT
and HIDDEN_BUT_PRINTABLE
.
visibility
- field visibility flagpublic String getFieldName()
public void setFieldName(String fieldName)
fieldName
- the field namepublic String getDefaultText()
public void setDefaultText(String defaultText)
defaultText
- the default textpublic int getOptions()
public void setOptions(int options)
READ_ONLY
, REQUIRED
,
MULTILINE
, DO_NOT_SCROLL
,
PASSWORD
, FILE_SELECTION
,
DO_NOT_SPELL_CHECK
and EDIT
.
options
- the option flagspublic int getMaxCharacterLength()
public void setMaxCharacterLength(int maxCharacterLength)
maxCharacterLength
- the maximum length of the field’s text, in characterspublic String[] getChoices()
public void setChoices(String[] choices)
choices
- the choices to be presented to the userpublic String[] getChoiceExports()
public void setChoiceExports(String[] choiceExports)
null
then the choice values will also be used
as the export values.
choiceExports
- the export values in list/combo fieldspublic int getChoiceSelection()
public void setChoiceSelection(int choiceSelection)
choiceSelection
- the zero based index of the selected itemint getTopFirst()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |