public class PdfFormField extends PdfObjectWrapper<PdfDictionary>
AcroForm
.
To be able to be wrapped with this PdfObjectWrapper
the PdfObject
must be indirect.
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_CENTER |
static int |
ALIGN_LEFT |
static int |
ALIGN_RIGHT |
protected Color |
backgroundColor |
protected Color |
borderColor |
protected float |
borderWidth |
protected static String |
check |
protected int |
checkType |
protected static String |
circle |
protected Color |
color |
protected static String |
cross |
static int |
DA_COLOR |
static int |
DA_FONT |
static int |
DA_SIZE |
static int |
DEFAULT_FONT_SIZE
Size of text in form fields when font size is not explicitly set.
|
protected static String |
diamond |
static int |
FF_MULTILINE
Flag that designates, if set, that the field can contain multiple lines of text.
|
static int |
FF_NO_EXPORT |
static int |
FF_PASSWORD
Flag that designates, if set, that the field's contents must be obfuscated.
|
static int |
FF_READ_ONLY |
static int |
FF_REQUIRED |
protected PdfFont |
font |
protected float |
fontSize |
protected PdfFormXObject |
form |
static int |
HIDDEN |
static int |
HIDDEN_BUT_PRINTABLE |
protected ImageData |
img |
protected PdfAConformanceLevel |
pdfAConformanceLevel |
protected int |
rotation |
protected static String |
square |
protected static String |
star |
protected String |
text |
static int |
TYPE_CHECK
A field with the symbol check
|
static int |
TYPE_CIRCLE
A field with the symbol circle
|
static int |
TYPE_CROSS
A field with the symbol cross
|
static int |
TYPE_DIAMOND
A field with the symbol diamond
|
static int |
TYPE_SQUARE
A field with the symbol square
|
static int |
TYPE_STAR
A field with the symbol star
|
protected static String[] |
typeChars |
static int |
VISIBLE_BUT_DOES_NOT_PRINT |
Modifier | Constructor and Description |
---|---|
|
PdfFormField(PdfDictionary pdfObject)
Creates a form field as a wrapper object around a PdfDictionary .
|
protected |
PdfFormField(PdfDocument pdfDocument)
Creates a minimal PdfFormField .
|
protected |
PdfFormField(PdfWidgetAnnotation widget, PdfDocument pdfDocument)
Creates a form field as a parent of a PdfWidgetAnnotation .
|
Modifier and Type | Method and Description |
---|---|
PdfFormField |
addKid(PdfFormField kid)
Adds a new kid to the Kids array property from a PdfFormField .
|
PdfFormField |
addKid(PdfWidgetAnnotation kid)
Adds a new kid to the Kids array property from a PdfWidgetAnnotation .
|
static PdfButtonFormField |
createButton(PdfDocument doc, int flags)
Creates an empty button form field with custom behavior and layout.
|
static PdfButtonFormField |
createButton(PdfDocument doc, Rectangle rect, int flags)
Creates an empty button form field with custom behavior and layout, on a specified location.
|
static PdfButtonFormField |
createCheckBox(PdfDocument doc, Rectangle rect, String name, String value)
Creates a PdfButtonFormField as a checkbox.
|
static PdfButtonFormField |
createCheckBox(PdfDocument doc, Rectangle rect, String name, String value, int checkType)
Creates a PdfButtonFormField as a checkbox.
|
static PdfButtonFormField |
createCheckBox(PdfDocument doc, Rectangle rect, String name, String value, int checkType, PdfAConformanceLevel pdfAConformanceLevel)
Creates a PdfButtonFormField as a checkbox.
|
static PdfChoiceFormField |
createChoice(PdfDocument doc, int flags)
Creates an empty choice form field .
|
static PdfChoiceFormField |
createChoice(PdfDocument doc, Rectangle rect, int flags)
Creates an empty choice form field with custom behavior and layout, on a specified location.
|
static PdfChoiceFormField |
createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfArray options, int flags)
Creates a choice form field with custom behavior and layout, on a specified location.
|
static PdfChoiceFormField |
createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, PdfArray options, int flags)
Creates a choice form field with custom behavior and layout, on a specified location.
|
static PdfChoiceFormField |
createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize, PdfArray options, int flags)
Deprecated.
Will be removed in 7.1. Use
createChoice(PdfDocument, Rectangle, String, String, PdfFont, float, PdfArray, int) instead
|
static PdfChoiceFormField |
createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[] options)
Creates a combobox with custom behavior and layout, on a specified location.
|
static PdfChoiceFormField |
createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[][] options)
Creates a combobox with custom behavior and layout, on a specified location.
|
static PdfFormField |
createEmptyField(PdfDocument doc)
Creates an empty form field without a predefined set of layout or behavior.
|
static PdfChoiceFormField |
createList(PdfDocument doc, Rectangle rect, String name, String value, String[] options)
Creates a list field with custom behavior and layout, on a specified location.
|
static PdfChoiceFormField |
createList(PdfDocument doc, Rectangle rect, String name, String value, String[][] options)
Creates a list field with custom behavior and layout, on a specified location.
|
static PdfTextFormField |
createMultilineText(PdfDocument doc, Rectangle rect, String name, String value)
Creates a named multiline text form field with an initial value, and the form's default font specified in PdfAcroForm.getDefaultResources() .
|
static PdfTextFormField |
createMultilineText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize)
Creates a named multilined text form field with an initial value, with a specified font and font size.
|
static PdfTextFormField |
createMultilineText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize)
Deprecated.
|
static PdfButtonFormField |
createPushButton(PdfDocument doc, Rectangle rect, String name, String caption)
Creates a PdfButtonFormField as a push button without data.
|
static PdfButtonFormField |
createPushButton(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, float fontSize)
Creates a PdfButtonFormField as a push button without data, with its caption in a custom font.
|
static PdfButtonFormField |
createPushButton(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, int fontSize)
Deprecated.
Will be removed in 7.1. Use
createPushButton(PdfDocument, Rectangle, String, String, PdfFont, float) instead.
|
static PdfFormField |
createRadioButton(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value)
Creates a generic PdfFormField that is added to a radio group.
|
static PdfFormField |
createRadioButton(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value, PdfAConformanceLevel pdfAConformanceLevel)
Creates a generic PdfFormField that is added to a radio group.
|
static PdfButtonFormField |
createRadioGroup(PdfDocument doc, String name, String value)
Creates a radio group form field .
|
static PdfSignatureFormField |
createSignature(PdfDocument doc)
Creates an empty signature form field .
|
static PdfSignatureFormField |
createSignature(PdfDocument doc, Rectangle rect)
Creates an empty signature form field .
|
static PdfTextFormField |
createText(PdfDocument doc)
Creates an empty text form field .
|
static PdfTextFormField |
createText(PdfDocument doc, Rectangle rect)
Creates an empty text form field .
|
static PdfTextFormField |
createText(PdfDocument doc, Rectangle rect, String name)
Creates a named text form field with an initial value, and the form's default font specified in PdfAcroForm.getDefaultResources() .
|
static PdfTextFormField |
createText(PdfDocument doc, Rectangle rect, String name, String value)
Creates a named text form field with an initial value, and the form's default font specified in PdfAcroForm.getDefaultResources() .
|
static PdfTextFormField |
createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize)
Creates a named text form field with an initial value, with a specified font and font size.
|
static PdfTextFormField |
createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, boolean multiline)
Creates a named text form field with an initial value, with a specified font and font size.
|
static PdfTextFormField |
createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize)
Deprecated.
Will be removed in 7.1. Use
createText(PdfDocument, Rectangle, String, String, PdfFont, float) instead.
|
static PdfTextFormField |
createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize, boolean multiline)
Deprecated.
Will be removed in 7.1. Use
createText(PdfDocument, Rectangle, String, String, PdfFont, float, boolean) instead.
|
protected void |
drawBorder(PdfCanvas canvas, PdfFormXObject xObject, float width, float height)
Draws a border using the borderWidth and borderColor of the form field.
|
protected void |
drawButton(PdfCanvas canvas, float x, float y, float width, float height, String text, PdfFont font, float fontSize)
Performs the low-level drawing operations to draw a button object.
|
protected void |
drawButton(PdfCanvas canvas, float x, float y, float width, float height, String text, PdfFont font, int fontSize)
Deprecated.
Will be removed in 7.1. Use
drawButton(PdfCanvas, float, float, float, float, String, PdfFont, float) instead.
|
protected void |
drawCheckAppearance(float width, float height, String value)
Draws the appearance of a checkbox with a specified state value.
|
protected void |
drawCheckBox(PdfCanvas canvas, float width, float height, float fontSize, boolean on)
Performs the low-level drawing operations to draw a checkbox object.
|
protected void |
drawCheckBox(PdfCanvas canvas, float width, float height, int fontSize, boolean on)
Deprecated.
Will be removed in 7.1. Use
drawCheckBox(PdfCanvas, float, float, float, boolean) instead.
|
protected void |
drawMultiLineTextAppearance(Rectangle rect, PdfFont font, float fontSize, String value, PdfFormXObject appearance)
Draws the visual appearance of multiline text in a form field.
|
protected void |
drawMultiLineTextAppearance(Rectangle rect, PdfFont font, int fontSize, String value, PdfFormXObject appearance)
Deprecated.
Will be removed in 7.1. Use
drawMultiLineTextAppearance(Rectangle, PdfFont, float, String, PdfFormXObject) instead.
|
protected void |
drawPdfA1CheckAppearance(float width, float height, String value, int checkType) |
protected void |
drawPdfA1RadioAppearance(float width, float height, String value)
Draws the appearance of a radio button with a specified value.
|
protected void |
drawPdfA2CheckAppearance(float width, float height, String value, int checkType) |
protected void |
drawPdfACheckBox(PdfCanvas canvas, float width, float height, boolean on) |
protected PdfFormXObject |
drawPushButtonAppearance(float width, float height, String text, PdfFont font, float fontSize)
Draws the appearance for a push button.
|
protected PdfFormXObject |
drawPushButtonAppearance(float width, float height, String text, PdfFont font, int fontSize)
Deprecated.
Will be removed in 7.1. Use
drawPushButtonAppearance(float, float, String, PdfFont, float) instead.
|
protected void |
drawRadioAppearance(float width, float height, String value)
Draws the appearance of a radio button with a specified value.
|
protected void |
drawRadioBorder(PdfCanvas canvas, PdfFormXObject xObject, float width, float height) |
protected void |
drawRadioField(PdfCanvas canvas, float width, float height, boolean on)
Draws a radio button.
|
protected void |
drawTextAppearance(Rectangle rect, PdfFont font, float fontSize, String value, PdfFormXObject appearance)
Draws the visual appearance of text in a form field.
|
protected void |
drawTextAppearance(Rectangle rect, PdfFont font, int fontSize, String value, PdfFormXObject appearance)
Deprecated.
Will be removed in 7.1. Use
drawTextAppearance(Rectangle, PdfFont, float, String, PdfFormXObject) instead.
|
protected String |
generateDefaultAppearanceString(PdfFont font, float fontSize, Color color, PdfResources res) |
protected String |
generateDefaultAppearanceString(PdfFont font, int fontSize, PdfResources res)
Deprecated.
Will be removed in 7.1. Use
generateDefaultAppearanceString(PdfFont, float, Color, PdfResources) instead.
|
PdfDictionary |
getAdditionalAction()
Gets the currently additional action dictionary for the form field.
|
PdfString |
getAlternativeName()
Gets the current alternate name.
|
String[] |
getAppearanceStates()
Gets the appearance state names.
|
float |
getBorderWidth()
Gets the border width for the field.
|
PdfString |
getDefaultAppearance()
Gets default appearance string containing a sequence of valid page-content graphics or text state operators that define such properties as the field's text size and color.
|
PdfString |
getDefaultStyle()
Gets a default style string, as described in "Rich Text Strings" section of Pdf spec.
|
PdfObject |
getDefaultValue()
Gets the default fallback value for the form field.
|
protected PdfDocument |
getDocument() |
boolean |
getFieldFlag(int flag)
Checks whether a certain flag, or any of a combination of flags, is set for this form field.
|
int |
getFieldFlags()
Gets the current list of PDF form field flags.
|
PdfString |
getFieldName()
Gets the current field name.
|
PdfFont |
getFont()
Gets the current font of the form field.
|
protected Object[] |
getFontAndSize(PdfDictionary asNormal) |
PdfName |
getFormType()
Returns the type of the
|
Integer |
getJustification()
Gets a code specifying the form of quadding (justification) to be used in displaying the text: 0 Left-justified 1 Centered 2 Right-justified
|
PdfArray |
getKids()
Gets the kids of this object.
|
PdfString |
getMappingName()
Gets the current mapping name.
|
PdfArray |
getOptions()
Gets options for the form field.
|
PdfDictionary |
getParent()
Gets the parent dictionary.
|
protected Rectangle |
getRect(PdfDictionary field) |
PdfObject |
getRichText()
Gets a rich text string, as described in "Rich Text Strings" section of Pdf spec.
|
PdfObject |
getValue()
Gets the current value contained in the form field.
|
String |
getValueAsString()
Gets the current value contained in the form field.
|
List<PdfWidgetAnnotation> |
getWidgets()
Gets all PdfWidgetAnnotation that this form field and its kids refer to.
|
boolean |
isMultiline()
If true, the field can contain multiple lines of text; if false, the field's text is restricted to a single line.
|
boolean |
isNoExport()
Gets the NoExport attribute.
|
boolean |
isPassword()
If true, the field is intended for entering a secure password that should not be echoed visibly to the screen.
|
boolean |
isReadOnly()
Gets the ReadOnly flag, specifying whether or not the field can be changed.
|
boolean |
isRequired()
Gets the Required flag, specifying whether or not the field must be filled in.
|
protected boolean |
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.
|
static int |
makeFieldFlag(int bitPosition)
Makes a field flag by bit position.
|
static PdfFormField |
makeFormField(PdfObject pdfObject, PdfDocument document)
Creates a (subtype of) PdfFormField object.
|
protected static PdfArray |
processOptions(String[] options) |
protected static PdfArray |
processOptions(String[][] options) |
PdfFormField |
put(PdfName key, PdfObject value) |
boolean |
regenerateField()
This method regenerates appearance stream of the field.
|
void |
release()
Releases underlying pdf object and other pdf entities used by wrapper.
|
PdfFormField |
setAction(PdfAction action)
Sets the action on all widgets of this form field.
|
PdfFormField |
setAdditionalAction(PdfName key, PdfAction action)
Sets an additional action for the form field.
|
PdfFormField |
setAlternativeName(String name)
Changes the alternate name of the field to the specified value.
|
PdfFormField |
setAppearance(PdfName appearanceType, String appearanceState, PdfStream appearanceStream)
Sets an appearance for (the widgets related to) the form field.
|
PdfFormField |
setBackgroundColor(Color backgroundColor)
Basic setter for the backgroundColor property.
|
PdfFormField |
setBorderColor(Color color)
Sets the Border Color.
|
PdfFormField |
setBorderStyle(PdfDictionary style) |
PdfFormField |
setBorderWidth(float borderWidth)
Sets the border width for the field.
|
PdfFormField |
setCheckType(int checkType)
Changes the type of graphical marker used to mark a checkbox as 'on'.
|
PdfFormField |
setColor(Color color)
Sets the text color.
|
PdfFormField |
setDefaultAppearance(String defaultAppearance)
Sets default appearance string containing a sequence of valid page-content graphics or text state operators that define such properties as the field's text size and color.
|
PdfFormField |
setDefaultStyle(PdfString defaultStyleString)
Sets a default style string, as described in "Rich Text Strings" section of Pdf spec.
|
PdfFormField |
setDefaultValue(PdfObject value)
Sets the default fallback value for the form field.
|
PdfFormField |
setFieldFlag(int flag)
Adds a flag, or combination of flags, for the form field.
|
PdfFormField |
setFieldFlag(int flag, boolean value)
Adds or removes a flag, or combination of flags, for the form field.
|
PdfFormField |
setFieldFlags(int flags)
Sets a flag, or combination of flags, for the form field.
|
PdfFormField |
setFieldName(String name)
Changes the name of the field to the specified value.
|
PdfFormField |
setFont(PdfFont font)
Basic setter for the font property.
|
PdfFormField |
setFontAndSize(PdfFont font, int fontSize)
Combined setter for the font and fontSize properties.
|
PdfFormField |
setFontSize(float fontSize)
Basic setter for the fontSize property.
|
PdfFormField |
setFontSize(int fontSize)
Basic setter for the fontSize property.
|
PdfFormField |
setJustification(int justification)
Sets a code specifying the form of quadding (justification) to be used in displaying the text: 0 Left-justified 1 Centered 2 Right-justified
|
PdfFormField |
setMappingName(String name)
Changes the mapping name of the field to the specified value.
|
PdfFormField |
setNoExport(boolean noExport)
Sets the NoExport flag, specifying whether or not exporting is forbidden.
|
PdfFormField |
setOptions(PdfArray options)
Sets options for the form field.
|
PdfFormField |
setPage(int pageNum)
Specifies on which page the form field's widget must be shown.
|
PdfFormField |
setParent(PdfFormField parent)
Sets a parent PdfFormField for the current object.
|
PdfFormField |
setReadOnly(boolean readOnly)
Sets the ReadOnly flag, specifying whether or not the field can be changed.
|
PdfFormField |
setRequired(boolean required)
Sets the Required flag, specifying whether or not the field must be filled in.
|
PdfFormField |
setRichText(PdfObject richText)
Sets a rich text string, as described in "Rich Text Strings" section of Pdf spec.
|
PdfFormField |
setRotation(int degRotation)
Basic setter for the degRotation property.
|
PdfFormField |
setValue(String value)
Sets a value to the field and generating field appearance if needed.
|
PdfFormField |
setValue(String value, boolean generateAppearance)
Sets a value to the field and generating field appearance if needed.
|
PdfFormField |
setValue(String value, PdfFont font, float fontSize)
Set text field value with given font and size
|
PdfFormField |
setValue(String value, PdfFont font, int fontSize)
Deprecated.
Use
setValue(String, PdfFont, float) instead
|
PdfFormField |
setValue(String value, String display)
Sets the field value and the display string.
|
PdfFormField |
setVisibility(int visibility) |
protected static Object[] |
splitDAelements(String da) |
ensureObjectIsAddedToDocument, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
public static final int FF_MULTILINE
public static final int FF_PASSWORD
public static final int DEFAULT_FONT_SIZE
public static final int DA_FONT
public static final int DA_SIZE
public static final int DA_COLOR
public static final int ALIGN_LEFT
public static final int ALIGN_CENTER
public static final int ALIGN_RIGHT
public static final int TYPE_CHECK
public static final int TYPE_CIRCLE
public static final int TYPE_CROSS
public static final int TYPE_DIAMOND
public static final int TYPE_SQUARE
public static final int TYPE_STAR
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 FF_READ_ONLY
public static final int FF_REQUIRED
public static final int FF_NO_EXPORT
protected static String[] typeChars
protected String text
protected ImageData img
protected PdfFont font
protected float fontSize
protected Color color
protected int checkType
protected float borderWidth
protected Color backgroundColor
protected Color borderColor
protected int rotation
protected PdfFormXObject form
protected PdfAConformanceLevel pdfAConformanceLevel
protected static final String check
protected static final String circle
protected static final String cross
protected static final String diamond
protected static final String square
protected static final String star
public PdfFormField(PdfDictionary pdfObject)
PdfDictionary
. This PdfDictionary
must be an indirect object.
pdfObject
- the dictionary to be wrapped, must have an indirect reference.
protected PdfFormField(PdfDocument pdfDocument)
PdfFormField
.
protected PdfFormField(PdfWidgetAnnotation widget, PdfDocument pdfDocument)
PdfWidgetAnnotation
.
widget
- the widget which will be a kid of the PdfFormField
public static int makeFieldFlag(int bitPosition)
bitPosition
- bit position of a flag in range 1 to 32 from the pdf specification.
public static PdfFormField createEmptyField(PdfDocument doc)
doc
- the PdfDocument
to create the field in
PdfFormField
public static PdfButtonFormField createButton(PdfDocument doc, Rectangle rect, int flags)
button form field
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the button field in
rect
- the location on the page for the button
flags
- an int
, containing a set of binary behavioral flags. Do binary OR
on this int
to set the flags you require.
PdfButtonFormField
public static PdfButtonFormField createButton(PdfDocument doc, int flags)
button form field
with custom behavior and layout.
doc
- the PdfDocument
to create the button field in
flags
- an int
, containing a set of binary behavioral flags. Do binary OR
on this int
to set the flags you require.
PdfButtonFormField
public static PdfTextFormField createText(PdfDocument doc)
text form field
.
doc
- the PdfDocument
to create the text field in
PdfTextFormField
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect)
text form field
.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
PdfTextFormField
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name)
text form field
with an initial value, and the form's default font specified in PdfAcroForm.getDefaultResources()
.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
PdfTextFormField
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value)
text form field
with an initial value, and the form's default font specified in PdfAcroForm.getDefaultResources()
.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
PdfTextFormField
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize)
text form field
with an initial value, with a specified font and font size.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
PdfTextFormField
@Deprecated public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize)
createText(PdfDocument, Rectangle, String, String, PdfFont, float)
instead.
text form field
with an initial value, with a specified font and font size.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
PdfTextFormField
@Deprecated public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize, boolean multiline)
createText(PdfDocument, Rectangle, String, String, PdfFont, float, boolean)
instead.
text form field
with an initial value, with a specified font and font size.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
multiline
- true for multiline text field
PdfTextFormField
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, boolean multiline)
text form field
with an initial value, with a specified font and font size.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
multiline
- true for multiline text field
PdfTextFormField
public static PdfTextFormField createMultilineText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize)
multilined text form field
with an initial value, with a specified font and font size.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
PdfTextFormField
@Deprecated public static PdfTextFormField createMultilineText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize)
createMultilineText(PdfDocument, Rectangle, String, String, PdfFont, float)
instead
multilined text form field
with an initial value, with a specified font and font size.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
PdfTextFormField
public static PdfTextFormField createMultilineText(PdfDocument doc, Rectangle rect, String name, String value)
multiline text form field
with an initial value, and the form's default font specified in PdfAcroForm.getDefaultResources()
.
doc
- the PdfDocument
to create the text field in
rect
- the location on the page for the text field
name
- the name of the form field
value
- the initial value
PdfTextFormField
public static PdfChoiceFormField createChoice(PdfDocument doc, int flags)
choice form field
.
doc
- the PdfDocument
to create the choice field in
flags
- an int
, containing a set of binary behavioral flags. Do binary OR
on this int
to set the flags you require.
PdfChoiceFormField
public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, int flags)
choice form field
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the choice field in
rect
- the location on the page for the choice field
flags
- an int
, containing a set of binary behavioral flags. Do binary OR
on this int
to set the flags you require.
PdfChoiceFormField
public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfArray options, int flags)
choice form field
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the choice field in
rect
- the location on the page for the choice field
name
- the name of the form field
value
- the initial value
options
- an array of PdfString
objects that each represent the 'on' state of one of the choices.
flags
- an int
, containing a set of binary behavioral flags. Do binary OR
on this int
to set the flags you require.
PdfChoiceFormField
@Deprecated public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, int fontSize, PdfArray options, int flags)
createChoice(PdfDocument, Rectangle, String, String, PdfFont, float, PdfArray, int)
instead
choice form field
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the choice field in
rect
- the location on the page for the choice field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
options
- an array of PdfString
objects that each represent the 'on' state of one of the choices.
flags
- an int
, containing a set of binary behavioral flags. Do binary OR
on this int
to set the flags you require.
PdfChoiceFormField
public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, PdfArray options, int flags)
choice form field
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the choice field in
rect
- the location on the page for the choice field
name
- the name of the form field
value
- the initial value
font
- a PdfFont
fontSize
- the size of the font
options
- an array of PdfString
objects that each represent the 'on' state of one of the choices.
flags
- an int
, containing a set of binary behavioral flags. Do binary OR
on this int
to set the flags you require.
PdfChoiceFormField
public static PdfSignatureFormField createSignature(PdfDocument doc)
signature form field
.
doc
- the PdfDocument
to create the signature field in
PdfSignatureFormField
public static PdfSignatureFormField createSignature(PdfDocument doc, Rectangle rect)
signature form field
.
doc
- the PdfDocument
to create the signature field in
rect
- the location on the page for the signature field
PdfSignatureFormField
public static PdfButtonFormField createRadioGroup(PdfDocument doc, String name, String value)
radio group form field
.
doc
- the PdfDocument
to create the radio group in
name
- the name of the form field
value
- the initial value
radio group
public static PdfFormField createRadioButton(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value)
PdfFormField
that is added to a radio group.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
radioGroup
- the radio button group that this field should belong to
value
- the initial value
PdfFormField
createRadioGroup(com.itextpdf.kernel.pdf.PdfDocument, java.lang.String, java.lang.String)
public static PdfFormField createRadioButton(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value, PdfAConformanceLevel pdfAConformanceLevel)
PdfFormField
that is added to a radio group.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
radioGroup
- the radio button group that this field should belong to
value
- the initial value
pdfAConformanceLevel
- the PdfAConformanceLevel
of the document. null if it's no PDF/A document
PdfFormField
createRadioGroup(com.itextpdf.kernel.pdf.PdfDocument, java.lang.String, java.lang.String)
public static PdfButtonFormField createPushButton(PdfDocument doc, Rectangle rect, String name, String caption)
PdfButtonFormField
as a push button without data.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
name
- the name of the form field
caption
- the text to display on the button
PdfButtonFormField
@Deprecated public static PdfButtonFormField createPushButton(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, int fontSize)
createPushButton(PdfDocument, Rectangle, String, String, PdfFont, float)
instead.
PdfButtonFormField
as a push button without data, with its caption in a custom font.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
name
- the name of the form field
caption
- the text to display on the button
font
- a PdfFont
fontSize
- the size of the font
PdfButtonFormField
public static PdfButtonFormField createPushButton(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, float fontSize)
PdfButtonFormField
as a push button without data, with its caption in a custom font.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
name
- the name of the form field
caption
- the text to display on the button
font
- a PdfFont
fontSize
- the size of the font
PdfButtonFormField
public static PdfButtonFormField createCheckBox(PdfDocument doc, Rectangle rect, String name, String value)
PdfButtonFormField
as a checkbox.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
name
- the name of the form field
value
- the initial value
checkbox
public static PdfButtonFormField createCheckBox(PdfDocument doc, Rectangle rect, String name, String value, int checkType)
PdfButtonFormField
as a checkbox.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
name
- the name of the form field
value
- the initial value
checkType
- the type of checkbox graphic to use.
checkbox
public static PdfButtonFormField createCheckBox(PdfDocument doc, Rectangle rect, String name, String value, int checkType, PdfAConformanceLevel pdfAConformanceLevel)
PdfButtonFormField
as a checkbox.
doc
- the PdfDocument
to create the radio group in
rect
- the location on the page for the field
name
- the name of the form field
value
- the initial value
checkType
- the type of checkbox graphic to use.
pdfAConformanceLevel
- the PdfAConformanceLevel
of the document. null if it's no PDF/A document
checkbox
public static PdfChoiceFormField createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[][] options)
combobox
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the combobox in
rect
- the location on the page for the combobox
name
- the name of the form field
value
- the initial value
options
- a two-dimensional array of Strings which will be converted to a PdfArray.
PdfChoiceFormField
as a combobox
public static PdfChoiceFormField createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[] options)
combobox
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the combobox in
rect
- the location on the page for the combobox
name
- the name of the form field
value
- the initial value
options
- an array of Strings which will be converted to a PdfArray.
PdfChoiceFormField
as a combobox
public static PdfChoiceFormField createList(PdfDocument doc, Rectangle rect, String name, String value, String[][] options)
list field
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the choice field in
rect
- the location on the page for the choice field
name
- the name of the form field
value
- the initial value
options
- a two-dimensional array of Strings which will be converted to a PdfArray.
PdfChoiceFormField
as a list field
public static PdfChoiceFormField createList(PdfDocument doc, Rectangle rect, String name, String value, String[] options)
list field
with custom behavior and layout, on a specified location.
doc
- the PdfDocument
to create the list field in
rect
- the location on the page for the list field
name
- the name of the form field
value
- the initial value
options
- an array of Strings which will be converted to a PdfArray.
PdfChoiceFormField
as a list field
public static PdfFormField makeFormField(PdfObject pdfObject, PdfDocument document)
PdfFormField
object. The type of the object depends on the FT
entry in the pdfObject
parameter.
pdfObject
- assumed to be either a PdfDictionary
, or a PdfIndirectReference
to a PdfDictionary
document
- the PdfDocument
to create the field in
PdfFormField
, or null
if pdfObject
does not contain a FT
entry
public PdfName getFormType()
Parent
form field, or of the wrappedPdfName
public PdfFormField setValue(String value)
value
- of the field
public PdfFormField setValue(String value, boolean generateAppearance)
value
- of the field
generateAppearance
- set this flat to false if you want to keep the appearance of the field generated before
@Deprecated public PdfFormField setValue(String value, PdfFont font, int fontSize)
setValue(String, PdfFont, float)
instead
value
- text value
font
- a PdfFont
fontSize
- the size of the font
public PdfFormField setValue(String value, PdfFont font, float fontSize)
value
- text value
font
- a PdfFont
fontSize
- the size of the font
public PdfFormField setValue(String value, String display)
value
- the field value
display
- the string that is used for the appearance. If null
the value
parameter will be used
public PdfFormField setParent(PdfFormField parent)
PdfFormField
for the current object.
parent
- another form field that this field belongs to, usually a group field
public PdfDictionary getParent()
public PdfArray getKids()
Kids
property, as a PdfArray
public PdfFormField addKid(PdfFormField kid)
Kids
array property from a PdfFormField
. Also sets the kid's Parent
property to this object.
kid
- a new PdfFormField
entry for the field's Kids
array property
public PdfFormField addKid(PdfWidgetAnnotation kid)
Kids
array property from a PdfWidgetAnnotation
. Also sets the kid's Parent
property to this object.
kid
- a new PdfWidgetAnnotation
entry for the field's Kids
array property
public PdfFormField setFieldName(String name)
name
- the new field name, as a String
public PdfString getFieldName()
PdfString
public PdfFormField setAlternativeName(String name)
name
- the new alternate name, as a String
public PdfString getAlternativeName()
PdfString
public PdfFormField setMappingName(String name)
name
- the new alternate name, as a String
public PdfString getMappingName()
PdfString
public boolean getFieldFlag(int flag)
flag
- an int
interpreted as a series of a binary flags
public PdfFormField setFieldFlag(int flag)
setFieldFlags(int)
.
flag
- an int
interpreted as a series of a binary flags
public PdfFormField setFieldFlag(int flag, boolean value)
setFieldFlags(int)
.
flag
- an int
interpreted as a series of a binary flags
value
- if true
, adds the flag(s). if false
, removes the flag(s).
public boolean isMultiline()
public boolean isPassword()
public PdfFormField setFieldFlags(int flags)
setFieldFlag(int)
which adds a flag to the existing flags.
flags
- an int
interpreted as a series of a binary flags
public int getFieldFlags()
int
public PdfObject getValue()
PdfObject
public String getValueAsString()
String
public PdfFormField setDefaultValue(PdfObject value)
value
- the default value
public PdfObject getDefaultValue()
public PdfFormField setAdditionalAction(PdfName key, PdfAction action)
key
- the dictionary key to use for storing the action
action
- the action
public PdfDictionary getAdditionalAction()
public PdfFormField setOptions(PdfArray options)
options
- an array of PdfString
objects that each represent the 'on' state of one of the choices.
public PdfArray getOptions()
public List<PdfWidgetAnnotation> getWidgets()
PdfWidgetAnnotation
that this form field and its kids
refer to.
PdfWidgetAnnotation
public PdfString getDefaultAppearance()
PdfString
public PdfFormField setDefaultAppearance(String defaultAppearance)
defaultAppearance
- a valid sequence of PDF content stream syntax
public Integer getJustification()
public PdfFormField setJustification(int justification)
justification
- the value to set the justification attribute to
public PdfString getDefaultStyle()
PdfString
public PdfFormField setDefaultStyle(PdfString defaultStyleString)
defaultStyleString
- a new default style for the form field
public PdfObject getRichText()
PdfStream
or PdfString
.
public PdfFormField setRichText(PdfObject richText)
PdfStream
or PdfString
.
richText
- a new rich text value
public PdfFormField setFont(PdfFont font)
font
property. Regenerates the field appearance after setting the new value.
font
- the new font to be set
public PdfFormField setFontSize(float fontSize)
fontSize
property. Regenerates the field appearance after setting the new value.
fontSize
- the new font size to be set
public PdfFormField setFontSize(int fontSize)
fontSize
property. Regenerates the field appearance after setting the new value.
fontSize
- the new font size to be set
public PdfFormField setFontAndSize(PdfFont font, int fontSize)
font
and fontSize
properties. Regenerates the field appearance after setting the new value.
font
- the new font to be set
fontSize
- the new font size to be set
public PdfFormField setBackgroundColor(Color backgroundColor)
backgroundColor
property. Regenerates the field appearance after setting the new value.
backgroundColor
- the new color to be set
public PdfFormField setRotation(int degRotation)
degRotation
property. Regenerates the field appearance after setting the new value.
degRotation
- the new degRotation to be set
public PdfFormField setAction(PdfAction action)
widgets
of this form field.
action
- the action
public PdfFormField setCheckType(int checkType)
regenerateField
method
checkType
- the new checkbox marker
public PdfFormField setVisibility(int visibility)
visibility
-
public boolean regenerateField()
public float getBorderWidth()
public PdfFormField setBorderWidth(float borderWidth)
borderWidth
- the new border width.
public PdfFormField setBorderStyle(PdfDictionary style)
public PdfFormField setBorderColor(Color color)
color
- the new value for the Border Color
public PdfFormField setColor(Color color)
color
- the new value for the Color
public PdfFormField setReadOnly(boolean readOnly)
readOnly
- if true
, then the field cannot be changed.
public boolean isReadOnly()
true
if the field cannot be changed.
public PdfFormField setRequired(boolean required)
required
- if true
, then the field must be filled in.
public boolean isRequired()
true
if the field must be filled in.
public PdfFormField setNoExport(boolean noExport)
noExport
- if true
, then exporting is forbidden
public boolean isNoExport()
public PdfFormField setPage(int pageNum)
pageNum
- the page number
public String[] getAppearanceStates()
public PdfFormField setAppearance(PdfName appearanceType, String appearanceState, PdfStream appearanceStream)
appearanceType
- the type of appearance stream to be added
appearanceState
- the state of the form field that needs to be true for the appearance to be used. Differentiates between several streams of the same type.
appearanceStream
- the appearance instructions, as a PdfStream
public PdfFormField put(PdfName key, PdfObject value)
public void release()
PdfObject.release()
if the wrapper is used.
protected boolean isWrappedObjectMustBeIndirect()
PdfObjectWrapper
isWrappedObjectMustBeIndirect
in class PdfObjectWrapper<PdfDictionary>
protected PdfDocument getDocument()
protected Rectangle getRect(PdfDictionary field)
protected String generateDefaultAppearanceString(PdfFont font, float fontSize, Color color, PdfResources res)
@Deprecated protected String generateDefaultAppearanceString(PdfFont font, int fontSize, PdfResources res)
generateDefaultAppearanceString(PdfFont, float, Color, PdfResources)
instead.
protected Object[] getFontAndSize(PdfDictionary asNormal) throws IOException
IOException
protected void drawTextAppearance(Rectangle rect, PdfFont font, float fontSize, String value, PdfFormXObject appearance)
rect
- the location on the page for the list field
font
- a PdfFont
fontSize
- the size of the font
value
- the initial value
@Deprecated protected void drawTextAppearance(Rectangle rect, PdfFont font, int fontSize, String value, PdfFormXObject appearance)
drawTextAppearance(Rectangle, PdfFont, float, String, PdfFormXObject)
instead.
rect
- the location on the page for the list field
font
- a PdfFont
fontSize
- the size of the font
value
- the initial value
protected void drawMultiLineTextAppearance(Rectangle rect, PdfFont font, float fontSize, String value, PdfFormXObject appearance)
rect
- the location on the page for the list field
font
- a PdfFont
fontSize
- the size of the font
value
- the initial value
@Deprecated protected void drawMultiLineTextAppearance(Rectangle rect, PdfFont font, int fontSize, String value, PdfFormXObject appearance)
drawMultiLineTextAppearance(Rectangle, PdfFont, float, String, PdfFormXObject)
instead.
rect
- the location on the page for the list field
font
- a PdfFont
fontSize
- the size of the font
value
- the initial value
protected void drawBorder(PdfCanvas canvas, PdfFormXObject xObject, float width, float height)
canvas
- the PdfCanvas
on which to draw
width
- the width of the rectangle to draw
height
- the height of the rectangle to draw
protected void drawRadioBorder(PdfCanvas canvas, PdfFormXObject xObject, float width, float height)
protected void drawRadioAppearance(float width, float height, String value)
width
- the width of the radio button to draw
height
- the height of the radio button to draw
value
- the value of the button
protected void drawPdfA1RadioAppearance(float width, float height, String value)
width
- the width of the radio button to draw
height
- the height of the radio button to draw
value
- the value of the button
protected void drawRadioField(PdfCanvas canvas, float width, float height, boolean on)
canvas
- the PdfCanvas
on which to draw
width
- the width of the radio button to draw
height
- the height of the radio button to draw
on
- required to be true
for fulfilling the drawing operation
protected void drawCheckAppearance(float width, float height, String value)
width
- the width of the checkbox to draw
height
- the height of the checkbox to draw
value
- the state of the form field that will be drawn
protected void drawPdfA1CheckAppearance(float width, float height, String value, int checkType)
protected void drawPdfA2CheckAppearance(float width, float height, String value, int checkType)
protected PdfFormXObject drawPushButtonAppearance(float width, float height, String text, PdfFont font, float fontSize)
width
- the width of the pushbutton
height
- the width of the pushbutton
text
- the text to display on the button
font
- a PdfFont
fontSize
- the size of the font
PdfFormXObject
@Deprecated protected PdfFormXObject drawPushButtonAppearance(float width, float height, String text, PdfFont font, int fontSize)
drawPushButtonAppearance(float, float, String, PdfFont, float)
instead.
width
- the width of the pushbutton
height
- the width of the pushbutton
text
- the text to display on the button
font
- a PdfFont
fontSize
- the size of the font
PdfFormXObject
protected void drawButton(PdfCanvas canvas, float x, float y, float width, float height, String text, PdfFont font, float fontSize)
canvas
- the PdfCanvas
of the page to draw on.
x
- the x coordinate of the lower left corner of the button rectangle
y
- the y coordinate of the lower left corner of the button rectangle
width
- the width of the button
height
- the width of the button
text
- the text to display on the button
font
- a PdfFont
fontSize
- the size of the font
@Deprecated protected void drawButton(PdfCanvas canvas, float x, float y, float width, float height, String text, PdfFont font, int fontSize)
drawButton(PdfCanvas, float, float, float, float, String, PdfFont, float)
instead.
canvas
- the PdfCanvas
of the page to draw on.
x
- the x coordinate of the lower left corner of the button rectangle
y
- the y coordinate of the lower left corner of the button rectangle
width
- the width of the button
height
- the width of the button
text
- the text to display on the button
font
- a PdfFont
fontSize
- the size of the font
protected void drawCheckBox(PdfCanvas canvas, float width, float height, float fontSize, boolean on)
canvas
- the PdfCanvas
of the page to draw on.
width
- the width of the button
height
- the width of the button
fontSize
- the size of the font
on
- the boolean value of the checkbox
@Deprecated protected void drawCheckBox(PdfCanvas canvas, float width, float height, int fontSize, boolean on)
drawCheckBox(PdfCanvas, float, float, float, boolean)
instead.
canvas
- the PdfCanvas
of the page to draw on.
width
- the width of the button
height
- the width of the button
fontSize
- the size of the font
on
- the boolean value of the checkbox
protected void drawPdfACheckBox(PdfCanvas canvas, float width, float height, boolean on)
Copyright © 1998–2016 iText Group NV. All rights reserved.