Package com.lowagie.text.pdf
Class BaseField
java.lang.Object
com.lowagie.text.pdf.BaseField
- Direct Known Subclasses:
PushbuttonField
,RadioCheckField
,TextField
Common field variables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected String
Holds the value of the alternate field name.protected Color
static final float
A medium border with 2 point width.static final float
A thick border with 3 point width.static final float
A thin border with 1 point width.protected Color
protected int
protected float
protected Rectangle
static final int
combo box flag.static final int
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 final int
The text entered in the field will not be spell-checked.static final int
If set the combo box includes an editable text box as well as a drop list; if clear, it includes only a drop list.protected String
Holds value of property fieldName.static final int
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
protected float
static final int
The field is hidden.static final int
The field is hidden but is printable.static final int
The annotation flag: Invisible.static final int
The annotation flag Hidden.protected String
Holds the value of the mapping field name.protected int
Holds value of property maxCharacterLength.static final int
The field may contain multiple lines of text.static final int
whether or not a list may have multiple selections.static final int
The annotation flag Hidden.protected int
Holds value of property options.static final int
The field is intended for entering a secure password that should not be echoed visibly to the screen.static final int
The annotation flag Hidden.static final int
The user may not change the value of the field.static final int
The field must have a value at the time it is exported by a submit-form action.protected int
Holds value of property rotation.protected String
protected Color
protected int
Holds value of property visibility.static final int
The field is visible.static final int
The field is visible but does not print.protected PdfWriter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbreakLines
(List<String> breaks, BaseFont font, float fontSize, float width) private static void
drawBottomFrame
(PdfAppearance app, float borderWidth, Rectangle box) private static void
drawTopFrame
(PdfAppearance app, float borderWidth, Rectangle box) int
Gets the text horizontal alignment.getAllHardBreaks
(String text) Gets the alternate field name.Gets the background color.protected static PdfAppearance
getBorderAppearance
(PdfWriter writer, Rectangle box, int rotation, Color backgroundColor, int borderStyle, float borderWidth, Color borderColor, int options, int maxCharacterLength) Gets the border color.int
Gets the border style.float
Gets the border width in points.getBox()
Gets the field dimension and position.Gets the field name.getFont()
Gets the text font.float
Gets the font size.Gets the mapping name.int
Gets the maximum length of the field's text, in characters.int
Gets the option flags.protected BaseFont
int
Gets the field rotation.getText()
Gets the text.Gets the text color.int
Gets the field visibility flag.Getter for property writer.static void
moveFields
(PdfDictionary from, PdfDictionary to) Moves the field keys fromfrom
toto
.void
setAlignment
(int alignment) Sets the text horizontal alignment.void
setAlternateFieldName
(String alternateFieldName) Sets the alternateFieldName field name.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
Sets the field dimension and position.void
setFieldName
(String fieldName) Sets the field name.void
Sets the text font.void
setFontSize
(float fontSize) Sets the font size.void
setMappingName
(String mappingName) Sets the mapping name.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
Sets the text for text fields.void
setTextColor
(Color textColor) Sets the text color.void
setVisibility
(int visibility) Sets the field visibility flag.void
Setter for property writer.protected static void
trimRight
(StringBuffer buf)
-
Field Details
-
BORDER_WIDTH_THIN
public static final float BORDER_WIDTH_THINA thin border with 1 point width.- See Also:
-
BORDER_WIDTH_MEDIUM
public static final float BORDER_WIDTH_MEDIUMA medium border with 2 point width.- See Also:
-
BORDER_WIDTH_THICK
public static final float BORDER_WIDTH_THICKA thick border with 3 point width.- See Also:
-
VISIBLE
public static final int VISIBLEThe field is visible.- See Also:
-
HIDDEN
public static final int HIDDENThe field is hidden.- See Also:
-
VISIBLE_BUT_DOES_NOT_PRINT
public static final int VISIBLE_BUT_DOES_NOT_PRINTThe field is visible but does not print.- See Also:
-
HIDDEN_BUT_PRINTABLE
public static final int HIDDEN_BUT_PRINTABLEThe field is hidden but is printable.- See Also:
-
INVISIBLE
public static final int INVISIBLEThe annotation flag: Invisible.- See Also:
-
PRINT
public static final int PRINTThe annotation flag Hidden.- See Also:
-
NOVIEW
public static final int NOVIEWThe annotation flag Hidden.- See Also:
-
LOCKED
public static final int LOCKEDThe annotation flag Hidden.- See Also:
-
READ_ONLY
public static final int READ_ONLYThe user may not change the value of the field.- See Also:
-
REQUIRED
public static final int REQUIREDThe field must have a value at the time it is exported by a submit-form action.- See Also:
-
MULTILINE
public static final int MULTILINEThe field may contain multiple lines of text. This flag is only meaningful with text fields.- See Also:
-
DO_NOT_SCROLL
public static final int DO_NOT_SCROLLThe 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. Once the field is full, no further text will be accepted.- See Also:
-
PASSWORD
public static final int PASSWORDThe field is intended for entering a secure password that should not be echoed visibly to the screen.- See Also:
-
FILE_SELECTION
public static final int FILE_SELECTIONThe text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.- See Also:
-
DO_NOT_SPELL_CHECK
public static final int DO_NOT_SPELL_CHECKThe text entered in the field will not be spell-checked. This flag is meaningful only in text fields and in combo fields with theEDIT
flag set.- See Also:
-
EDIT
public static final int EDITIf set the combo box includes an editable text box as well as a drop list; if clear, it includes only a drop list. This flag is only meaningful with combo fields.- See Also:
-
MULTISELECT
public static final int MULTISELECTwhether or not a list may have multiple selections. Only applies to /CH LIST fields, not combo boxes.- See Also:
-
COMB
public static final int COMBcombo box flag.- See Also:
-
fieldKeys
-
borderWidth
protected float borderWidth -
borderStyle
protected int borderStyle -
borderColor
-
backgroundColor
-
textColor
-
font
-
fontSize
protected float fontSize -
alignment
protected int alignment -
writer
-
text
-
box
-
rotation
protected int rotationHolds value of property rotation. -
visibility
protected int visibilityHolds value of property visibility. -
fieldName
Holds value of property fieldName. -
alternateFieldName
Holds the value of the alternate field name. (PDF attribute 'TU') -
mappingName
Holds the value of the mapping field name. (PDF attribute 'TM') -
options
protected int optionsHolds value of property options. -
maxCharacterLength
protected int maxCharacterLengthHolds value of property maxCharacterLength.
-
-
Constructor Details
-
BaseField
Creates a newTextField
.- Parameters:
writer
- the documentPdfWriter
box
- the field location and dimensionsfieldName
- the field name. Ifnull
only the widget keys will be included in the field allowing it to be used as a kid field.
-
-
Method Details
-
getBorderAppearance
protected static PdfAppearance getBorderAppearance(PdfWriter writer, Rectangle box, int rotation, Color backgroundColor, int borderStyle, float borderWidth, Color borderColor, int options, int maxCharacterLength) -
getAllHardBreaks
-
trimRight
-
breakLines
-
drawTopFrame
-
drawBottomFrame
-
moveFields
Moves the field keys fromfrom
toto
. The moved keys are removed fromfrom
.- Parameters:
from
- the sourceto
- the destination. It may benull
-
getRealFont
- Throws:
IOException
DocumentException
-
getBorderWidth
public float getBorderWidth()Gets the border width in points.- Returns:
- the border width in points
-
setBorderWidth
public void setBorderWidth(float borderWidth) Sets the border width in points. To eliminate the border set the border color tonull
.- Parameters:
borderWidth
- the border width in points
-
getBorderStyle
public int getBorderStyle()Gets the border style.- Returns:
- the border style
-
setBorderStyle
public void setBorderStyle(int borderStyle) Sets the border style. The styles are found inPdfBorderDictionary
and can beSTYLE_SOLID
,STYLE_DASHED
,STYLE_BEVELED
,STYLE_INSET
andSTYLE_UNDERLINE
.- Parameters:
borderStyle
- the border style
-
getBorderColor
Gets the border color.- Returns:
- the border color
-
setBorderColor
Sets the border color. Set tonull
to remove the border.- Parameters:
borderColor
- the border color
-
getBackgroundColor
Gets the background color.- Returns:
- the background color
-
setBackgroundColor
Sets the background color. Set tonull
for transparent background.- Parameters:
backgroundColor
- the background color
-
getTextColor
Gets the text color.- Returns:
- the text color
-
setTextColor
Sets the text color. Ifnull
the color used will be black.- Parameters:
textColor
- the text color
-
getFont
Gets the text font.- Returns:
- the text font
-
setFont
Sets the text font. Ifnull
then Helvetica will be used.- Parameters:
font
- the text font
-
getFontSize
public float getFontSize()Gets the font size.- Returns:
- the font size
-
setFontSize
public void setFontSize(float fontSize) Sets the font size. If 0 then auto-sizing will be used but only for text fields.- Parameters:
fontSize
- the font size
-
getAlignment
public int getAlignment()Gets the text horizontal alignment.- Returns:
- the text horizontal alignment
-
setAlignment
public void setAlignment(int alignment) Sets the text horizontal alignment. It can beElement.ALIGN_LEFT
,Element.ALIGN_CENTER
andElement.ALIGN_RIGHT
.- Parameters:
alignment
- the text horizontal alignment
-
getText
Gets the text.- Returns:
- the text
-
setText
Sets the text for text fields.- Parameters:
text
- the text
-
getBox
Gets the field dimension and position.- Returns:
- the field dimension and position
-
setBox
Sets the field dimension and position.- Parameters:
box
- the field dimension and position
-
getRotation
public int getRotation()Gets the field rotation.- Returns:
- the field rotation
-
setRotation
public void setRotation(int rotation) Sets the field rotation. This value should be the same as the page rotation where the field will be shown.- Parameters:
rotation
- the field rotation
-
setRotationFromPage
Convenience method to set the field rotation the same as the page rotation.- Parameters:
page
- the page
-
getVisibility
public int getVisibility()Gets the field visibility flag.- Returns:
- the field visibility flag
-
setVisibility
public void setVisibility(int visibility) Sets the field visibility flag. This flags can be one ofVISIBLE
,HIDDEN
,VISIBLE_BUT_DOES_NOT_PRINT
andHIDDEN_BUT_PRINTABLE
.- Parameters:
visibility
- field visibility flag
-
getFieldName
Gets the field name.- Returns:
- the field name
-
setFieldName
Sets the field name.- Parameters:
fieldName
- the field name. Ifnull
only the widget keys will be included in the field allowing it to be used as a kid field.
-
getAlternateFieldName
Gets the alternate field name. (PDF attribute TU)- Returns:
- the alternate field name
-
setAlternateFieldName
Sets the alternateFieldName field name.- Parameters:
alternateFieldName
- the alternate field name.
-
getMappingName
Gets the mapping name. (PDF attribute TM)- Returns:
- the mapping field name
-
setMappingName
Sets the mapping name. (PDF TM)- Parameters:
mappingName
- the mapping name.
-
getOptions
public int getOptions()Gets the option flags.- Returns:
- the option flags
-
setOptions
public void setOptions(int options) Sets the option flags. The option flags can be a combination by oring ofREAD_ONLY
,REQUIRED
,MULTILINE
,DO_NOT_SCROLL
,PASSWORD
,FILE_SELECTION
,DO_NOT_SPELL_CHECK
andEDIT
.- Parameters:
options
- the option flags
-
getMaxCharacterLength
public int getMaxCharacterLength()Gets the maximum length of the field's text, in characters.- Returns:
- the maximum length of the field's text, in characters.
-
setMaxCharacterLength
public void setMaxCharacterLength(int maxCharacterLength) Sets the maximum length of the field's text, in characters. It is only meaningful for text fields.- Parameters:
maxCharacterLength
- the maximum length of the field's text, in characters
-
getWriter
Getter for property writer.- Returns:
- Value of property writer.
-
setWriter
Setter for property writer.- Parameters:
writer
- New value of property writer.
-