Package com.lowagie.text.pdf
Class PdfAcroForm
- java.lang.Object
-
- com.lowagie.text.pdf.PdfObject
-
- com.lowagie.text.pdf.PdfDictionary
-
- com.lowagie.text.pdf.PdfAcroForm
-
public class PdfAcroForm extends PdfDictionary
Each PDF document can contain maximum 1 AcroForm.
-
-
Field Summary
Fields Modifier and Type Field Description private PdfArray
calculationOrder
This is an array containing the calculationorder of the fields.private PdfArray
documentFields
This is an array containing DocumentFields.private java.util.Map<PdfTemplate,java.lang.Object>
fieldTemplates
This is a map containing FieldTemplates.private int
sigFlags
Contains the signature flags.private PdfWriter
writer
-
Constructor Summary
Constructors Constructor Description PdfAcroForm(PdfWriter writer)
Creates new PdfAcroForm
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCalculationOrder(PdfFormField formField)
Adds an object to the calculationOrder.PdfFormField
addCheckBox(java.lang.String name, java.lang.String value, boolean status, float llx, float lly, float urx, float ury)
PdfFormField
addComboBox(java.lang.String name, java.lang.String[][] options, java.lang.String defaultValue, boolean editable, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
addComboBox(java.lang.String name, java.lang.String[] options, java.lang.String defaultValue, boolean editable, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
void
addDocumentField(PdfIndirectReference ref)
Adds documentFields.void
addFieldTemplates(java.util.Map<PdfTemplate,java.lang.Object> ft)
Adds fieldTemplates.void
addFormField(PdfFormField formField)
Adds a formfield to the AcroForm.PdfFormField
addHiddenField(java.lang.String name, java.lang.String value)
PdfFormField
addHtmlPostButton(java.lang.String name, java.lang.String caption, java.lang.String value, java.lang.String url, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
addMap(java.lang.String name, java.lang.String value, java.lang.String url, PdfContentByte appearance, float llx, float lly, float urx, float ury)
PdfFormField
addMultiLineTextField(java.lang.String name, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
addRadioButton(PdfFormField radiogroup, java.lang.String value, float llx, float lly, float urx, float ury)
void
addRadioGroup(PdfFormField radiogroup)
PdfFormField
addResetButton(java.lang.String name, java.lang.String caption, java.lang.String value, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
addSelectList(java.lang.String name, java.lang.String[][] options, java.lang.String defaultValue, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
addSelectList(java.lang.String name, java.lang.String[] options, java.lang.String defaultValue, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
addSignature(java.lang.String name, float llx, float lly, float urx, float ury)
PdfFormField
addSingleLinePasswordField(java.lang.String name, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
addSingleLineTextField(java.lang.String name, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
void
drawButton(PdfFormField button, java.lang.String caption, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
void
drawCheckBoxAppearences(PdfFormField field, java.lang.String value, float llx, float lly, float urx, float ury)
void
drawMultiLineOfText(PdfFormField field, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
void
drawRadioAppearences(PdfFormField field, java.lang.String value, float llx, float lly, float urx, float ury)
void
drawSignatureAppearences(PdfFormField field, float llx, float lly, float urx, float ury)
void
drawSingleLineOfText(PdfFormField field, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
PdfFormField
getRadioGroup(java.lang.String name, java.lang.String defaultValue, boolean noToggleToOff)
boolean
isValid()
Checks if the Acroform is validvoid
setButtonParams(PdfFormField button, int characteristics, java.lang.String name, java.lang.String value)
void
setCheckBoxParams(PdfFormField field, java.lang.String name, java.lang.String value, boolean status, float llx, float lly, float urx, float ury)
void
setChoiceParams(PdfFormField field, java.lang.String name, java.lang.String defaultValue, float llx, float lly, float urx, float ury)
void
setNeedAppearances(boolean value)
void
setSigFlags(int f)
Sets the signature flags.void
setSignatureParams(PdfFormField field, java.lang.String name, float llx, float lly, float urx, float ury)
void
setTextFieldParams(PdfFormField field, java.lang.String text, java.lang.String name, float llx, float lly, float urx, float ury)
-
Methods inherited from class com.lowagie.text.pdf.PdfDictionary
clear, contains, get, getAsArray, getAsBoolean, getAsDict, getAsIndirectObject, getAsName, getAsNumber, getAsStream, getAsString, getDirectObject, getKeys, getKeysAndValues, isCatalog, isFont, isOutlineTree, isPage, isPages, merge, mergeDifferent, put, putAll, putEx, remove, size, toPdf, toString
-
Methods inherited from class com.lowagie.text.pdf.PdfObject
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, type
-
-
-
-
Field Detail
-
writer
private PdfWriter writer
-
fieldTemplates
private java.util.Map<PdfTemplate,java.lang.Object> fieldTemplates
This is a map containing FieldTemplates.
-
documentFields
private PdfArray documentFields
This is an array containing DocumentFields.
-
calculationOrder
private PdfArray calculationOrder
This is an array containing the calculationorder of the fields.
-
sigFlags
private int sigFlags
Contains the signature flags.
-
-
Method Detail
-
setNeedAppearances
public void setNeedAppearances(boolean value)
-
addFieldTemplates
public void addFieldTemplates(java.util.Map<PdfTemplate,java.lang.Object> ft)
Adds fieldTemplates.- Parameters:
ft
- field templates
-
addDocumentField
public void addDocumentField(PdfIndirectReference ref)
Adds documentFields.- Parameters:
ref
- an object ofPdfIndirectReference
-
isValid
public boolean isValid()
Checks if the Acroform is valid- Returns:
- true if the Acroform is valid
-
addCalculationOrder
public void addCalculationOrder(PdfFormField formField)
Adds an object to the calculationOrder.- Parameters:
formField
- an object ofPdfFormField
-
setSigFlags
public void setSigFlags(int f)
Sets the signature flags.- Parameters:
f
- signature flag
-
addFormField
public void addFormField(PdfFormField formField)
Adds a formfield to the AcroForm.- Parameters:
formField
- an object ofPdfFormField
-
addHtmlPostButton
public PdfFormField addHtmlPostButton(java.lang.String name, java.lang.String caption, java.lang.String value, java.lang.String url, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldvalue
- value of the fieldurl
- url for the actioncaption
- captionfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
addResetButton
public PdfFormField addResetButton(java.lang.String name, java.lang.String caption, java.lang.String value, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldvalue
- value of the fieldcaption
- captionfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
addMap
public PdfFormField addMap(java.lang.String name, java.lang.String value, java.lang.String url, PdfContentByte appearance, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldvalue
- value of the fieldurl
- url of the actionappearance
- an object ofPdfContentByte
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
setButtonParams
public void setButtonParams(PdfFormField button, int characteristics, java.lang.String name, java.lang.String value)
- Parameters:
button
- an object ofPdfFormField
characteristics
- characteristicsname
- name of the fieldvalue
- value of the field
-
drawButton
public void drawButton(PdfFormField button, java.lang.String caption, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
button
- an object ofPdfFormField
caption
- captionfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
addHiddenField
public PdfFormField addHiddenField(java.lang.String name, java.lang.String value)
- Parameters:
name
- name of the fieldvalue
- value of the field- Returns:
- a PdfFormField
-
addSingleLineTextField
public PdfFormField addSingleLineTextField(java.lang.String name, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldtext
- value for fieldfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
addMultiLineTextField
public PdfFormField addMultiLineTextField(java.lang.String name, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldtext
- value for fieldfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
addSingleLinePasswordField
public PdfFormField addSingleLinePasswordField(java.lang.String name, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldtext
- text for the fieldfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- PdfFormField
-
setTextFieldParams
public void setTextFieldParams(PdfFormField field, java.lang.String text, java.lang.String name, float llx, float lly, float urx, float ury)
- Parameters:
field
- an object ofPdfFormField
text
- text for the fieldname
- name of the fieldllx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
drawSingleLineOfText
public void drawSingleLineOfText(PdfFormField field, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
field
- fieldtext
- text for the fieldfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
drawMultiLineOfText
public void drawMultiLineOfText(PdfFormField field, java.lang.String text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
field
- field, an object ofPdfFormField
text
- text for fieldfont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
addCheckBox
public PdfFormField addCheckBox(java.lang.String name, java.lang.String value, boolean status, float llx, float lly, float urx, float ury)
- Parameters:
name
- field namestatus
- statusvalue
- value of the fieldllx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
setCheckBoxParams
public void setCheckBoxParams(PdfFormField field, java.lang.String name, java.lang.String value, boolean status, float llx, float lly, float urx, float ury)
- Parameters:
name
- field namestatus
- statusfield
- field, an object ofPdfFormField
value
- value of the fieldllx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
drawCheckBoxAppearences
public void drawCheckBoxAppearences(PdfFormField field, java.lang.String value, float llx, float lly, float urx, float ury)
- Parameters:
field
- field, an object ofPdfFormField
value
- value of the fieldllx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
getRadioGroup
public PdfFormField getRadioGroup(java.lang.String name, java.lang.String defaultValue, boolean noToggleToOff)
- Parameters:
name
- name of the fielddefaultValue
- default valuenoToggleToOff
- noToggleToOff- Returns:
- a PdfFormField
-
addRadioGroup
public void addRadioGroup(PdfFormField radiogroup)
- Parameters:
radiogroup
- field
-
addRadioButton
public PdfFormField addRadioButton(PdfFormField radiogroup, java.lang.String value, float llx, float lly, float urx, float ury)
- Parameters:
radiogroup
- radio group fieldvalue
- value of the fieldllx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
drawRadioAppearences
public void drawRadioAppearences(PdfFormField field, java.lang.String value, float llx, float lly, float urx, float ury)
- Parameters:
field
- field, an object ofPdfFormField
value
- valuellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
addSelectList
public PdfFormField addSelectList(java.lang.String name, java.lang.String[] options, java.lang.String defaultValue, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldoptions
- optionsdefaultValue
- default valuefont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
addSelectList
public PdfFormField addSelectList(java.lang.String name, java.lang.String[][] options, java.lang.String defaultValue, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldoptions
- optionsdefaultValue
- default valuefont
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
addComboBox
public PdfFormField addComboBox(java.lang.String name, java.lang.String[] options, java.lang.String defaultValue, boolean editable, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldoptions
- optionsdefaultValue
- default valueeditable
- if field is editable,true
orfalse
font
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
addComboBox
public PdfFormField addComboBox(java.lang.String name, java.lang.String[][] options, java.lang.String defaultValue, boolean editable, BaseFont font, float fontSize, float llx, float lly, float urx, float ury)
- Parameters:
name
- name of the fieldoptions
- optionsdefaultValue
- default valueeditable
- if field is editable,true
orfalse
font
- an object ofBaseFont
fontSize
- font sizellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
setChoiceParams
public void setChoiceParams(PdfFormField field, java.lang.String name, java.lang.String defaultValue, float llx, float lly, float urx, float ury)
- Parameters:
field
- field, an object ofPdfFormField
name
- field namedefaultValue
- default caluellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
addSignature
public PdfFormField addSignature(java.lang.String name, float llx, float lly, float urx, float ury)
- Parameters:
name
- field namellx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y- Returns:
- a PdfFormField
-
setSignatureParams
public void setSignatureParams(PdfFormField field, java.lang.String name, float llx, float lly, float urx, float ury)
- Parameters:
name
- field namefield
- field, an object ofPdfFormField
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
drawSignatureAppearences
public void drawSignatureAppearences(PdfFormField field, float llx, float lly, float urx, float ury)
- Parameters:
field
- field, an object ofPdfFormField
llx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-y
-
-