Package com.lowagie.text.pdf
Class BaseField
java.lang.Object
com.lowagie.text.pdf.BaseField
- Direct Known Subclasses:
PushbuttonField,RadioCheckField,TextField
Common field variables.
- Author:
- Paulo Soares (psoares@consiste.pt)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected Colorstatic final floatA medium border with 2 point width.static final floatA thick border with 3 point width.static final floatA thin border with 1 point width.protected Colorprotected intprotected floatprotected Rectanglestatic final intcombo box flag.static final intThe 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 intThe text entered in the field will not be spell-checked.static final intIf set the combo box includes an editable text box as well as a drop list; if clear, it includes only a drop list.protected StringHolds value of property fieldName.static final intThe text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.protected BaseFontprotected floatstatic final intThe field is hidden.static final intThe field is hidden but is printable.protected intHolds value of property maxCharacterLength.static final intThe field may contain multiple lines of text.protected intHolds value of property options.static final intThe field is intended for entering a secure password that should not be echoed visibly to the screen.static final intThe user may not change the value of the field.static final intThe field must have a value at the time it is exported by a submit-form action.protected intHolds value of property rotation.protected Stringprotected Colorprotected intHolds value of property visibility.static final intThe field is visible.static final intThe field is visible but does not print.protected PdfWriter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static ArrayListbreakLines(ArrayList breaks, BaseFont font, float fontSize, float width) intGets the text horizontal alignment.Gets the background color.protected PdfAppearanceGets the border color.intGets the border style.floatGets the border width in points.getBox()Gets the field dimension and position.Gets the field name.getFont()Gets the text font.floatGets the font size.protected static ArrayListgetHardBreaks(String text) intGets the maximum length of the field's text, in characters.intGets the option flags.protected BaseFontintGets the field rotation.getText()Gets the text.Gets the text color.intGets the field visibility flag.Getter for property writer.static voidmoveFields(PdfDictionary from, PdfDictionary to) Moves the field keys fromfromtoto.voidsetAlignment(int alignment) Sets the text horizontal alignment.voidsetBackgroundColor(Color backgroundColor) Sets the background color.voidsetBorderColor(Color borderColor) Sets the border color.voidsetBorderStyle(int borderStyle) Sets the border style.voidsetBorderWidth(float borderWidth) Sets the border width in points.voidSets the field dimension and position.voidsetFieldName(String fieldName) Sets the field name.voidSets the text font.voidsetFontSize(float fontSize) Sets the font size.voidsetMaxCharacterLength(int maxCharacterLength) Sets the maximum length of the field's text, in characters.voidsetOptions(int options) Sets the option flags.voidsetRotation(int rotation) Sets the field rotation.voidsetRotationFromPage(Rectangle page) Convenience method to set the field rotation the same as the page rotation.voidSets the text for text fields.voidsetTextColor(Color textColor) Sets the text color.voidsetVisibility(int visibility) Sets the field visibility flag.voidSetter for property writer.protected static voidtrimRight(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:
-
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 theEDITflag 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:
-
COMB
public static final int COMBcombo box flag.- See Also:
-
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. -
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 documentPdfWriterbox- the field location and dimensionsfieldName- the field name. Ifnullonly the widget keys will be included in the field allowing it to be used as a kid field.
-
-
Method Details
-
getRealFont
- Throws:
IOExceptionDocumentException
-
getBorderAppearance
-
getHardBreaks
-
trimRight
-
breakLines
-
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 inPdfBorderDictionaryand can beSTYLE_SOLID,STYLE_DASHED,STYLE_BEVELED,STYLE_INSETandSTYLE_UNDERLINE.- Parameters:
borderStyle- the border style
-
getBorderColor
Gets the border color.- Returns:
- the border color
-
setBorderColor
Sets the border color. Set tonullto remove the border.- Parameters:
borderColor- the border color
-
getBackgroundColor
Gets the background color.- Returns:
- the background color
-
setBackgroundColor
Sets the background color. Set tonullfor transparent background.- Parameters:
backgroundColor- the background color
-
getTextColor
Gets the text color.- Returns:
- the text color
-
setTextColor
Sets the text color. Ifnullthe color used will be black.- Parameters:
textColor- the text color
-
getFont
Gets the text font.- Returns:
- the text font
-
setFont
Sets the text font. Ifnullthen 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_CENTERandElement.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_PRINTandHIDDEN_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. Ifnullonly the widget keys will be included in the field allowing it to be used as a kid field.
-
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_CHECKandEDIT.- 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.
-
moveFields
Moves the field keys fromfromtoto. The moved keys are removed fromfrom.- Parameters:
from- the sourceto- the destination. It may benull
-