FormEditor

Inheritance: java.lang.Object, com.aspose.pdf.facades.IVentureLicenseTarget, com.aspose.pdf.facades.Facade, com.aspose.pdf.facades.SaveableFacade, com.aspose.pdf.facades.AFormEditor

All Implemented Interfaces: com.aspose.pdf.facades.IFormEditor

public final class FormEditor extends AFormEditor implements IFormEditor

Class for editing forms (adding/deleting field etc)

Constructors

ConstructorDescription
FormEditor()Constructor for FormEditor.
FormEditor(IDocument document)Initializes new FormEditor object on base of the document .
FormEditor(IDocument document, OutputStream destStream)Initializes new FormEditor object on base of the document .
FormEditor(IDocument document, String destFileName)Initializes new FormEditor object on base of the document .
FormEditor(InputStream srcStream, OutputStream destStream)Constructor for FormEditor.
FormEditor(String srcFileName, String destFileName)Constructor for FormEditor

Methods

MethodDescription
getSrcFileName()Gets name of source file.
setSrcFileName(String value)Sets name of source file.
getDestFileName()Gets destination file name.
setDestFileName(String value)Sets destination file name.
getSrcStream()Gets source stream.
setSrcStream(InputStream value)Sets source stream.
setConvertTo(PdfFormat value)Sets PdfFormat PDF file format.
getDestStream()Gets destination stream.
setDestStream(OutputStream value)Sets destination stream.
getItems()Get Items which will be added to newly created list box or combo box.
setItems(String[] value)Sets items which will be added to newly created list box or combo box.
getExportItems()Gets options for combo box with export values.
setExportItems(String[][] value)Sets options for combo box with export values.
getFacade()Gets visual attributes of the field.
setFacade(FormFieldFacade value)Sets visual attributes of the field.
getRadioGap()Get the member to record the gap between two neighboring radio buttons in pixels,default is 50.
setRadioGap(float value)Set the member to record the gap between two neighboring radio buttons in pixels,default is 50.
getRadioHoriz()Get the flag to indicate whether the radios are arranged horizontally or vertically, default value is true.
setRadioHoriz(boolean value)Set the flag to indicate whether the radios are arranged horizontally or vertically, default value is true.
getRadioButtonItemSize()Gets or sets size of radio button item size (when new radio button field is added).
setRadioButtonItemSize(double value)Gets or sets size of radio button item size (when new radio button field is added).
getSubmitFlag()Get the submit button’s submission flags
setSubmitFlag(SubmitFormFlag value)Set the submit button’s submission flags
save()Saves changes into destination file.
setFieldAttribute(String fieldName, int flag)Set attributes of field.
setFieldAppearance(String fieldName, int flags)Set field flags
setSubmitFlag(String fieldName, SubmitFormFlag submitFormFlag)Set submit flag of submit button.
setSubmitUrl(String fieldName, String url)Sets URL of the button.
setFieldLimit(String fieldName, int fieldLimit)Sets maximum character count of the text field.
setFieldCombNumber(String fieldName, int combNumber)Sets number of combs for a regular single-line text field (the field is automatically divided into as many equally spaced positions, or combs, as the value of combNumber parameter).
moveField(String fieldName, float llx, float lly, float urx, float ury)Set new position of field.
addField(FieldType fieldType, String fieldName, int pageNum, float llx, float lly, float urx, float ury)Add field of specified type to the form.
addField(FieldType fieldType, String fieldName, String initValue, int pageNum, float llx, float lly, float urx, float ury)Add field of specified type to the form.
removeField(String fieldName)Remove field from the form.
resetFacade()Reset all visual attribtues to empty value.
resetInnerFacade()Reset all visual attribtues of inner facade to empty value.
copyInnerField(String fieldName, String newFieldName, int pageNum)Copies an existing field to the same position in specified page number.
copyInnerField(String fieldName, String newFieldName, int pageNum, float abscissa, float ordinate)Copies an existing field to a new position specified by both page number and ordinates.
copyOuterField(String srcFileName, String fieldName)Copies an existing field from one PDF document to another document with original page number and ordinates.
copyOuterField(String srcFileName, String fieldName, int pageNum)Copies an existing field from one PDF document to another document with specified page number and original ordinates.
copyOuterField(String srcFileName, String fieldName, int pageNum, float abscissa, float ordinate)Copies an existing field from one PDF document to another document with specified page number and ordinates.
decorateField(String fieldName)Changes visual attributes of the specified field.
decorateField(FieldType fieldType)Changes visual attributes of all fields with the specified field type.
decorateField()Changes visual attributes of all fields in the PDF document.
renameField(String fieldName, String newFieldName)Change name of the field.
removeFieldAction(String fieldName)Remove submit action of the field.
addSubmitBtn(String fieldName, int page, String label, String url, float llx, float lly, float urx, float ury)Add submit button on the form.
addListItem(String fieldName, String itemName)Adds new item to the list box.
addListItem(String fieldName, String[] exportName)Add a new item with Export value to the existing list box field, only for AcroForm combo box field.
delListItem(String fieldName, String itemName)Delete item from the list field.
setFieldScript(String fieldName, String script)Set JavaScript for a PushButton field.
single2Multiple(String fieldName)Change a single-lined text field to a multiple-lined one.
setFieldAlignment(String fieldName, int alignment)Set the alignment style of a text field.
setFieldAlignmentV(String fieldName, int alignment)Set the vertical alignment style of a text field.
getDocument()Gets the document FormEditor is working on.
getContentDisposition()Gets how content will be stored when result of operation is stored into HttpResponse object.
setContentDisposition(int value)Sets how content will be stored when result of operation is stored into HttpResponse object.
getSaveOptions()Gets save options when result is stored as HttpResponse.
setSaveOptions(SaveOptions value)Sets save options when result is stored as HttpResponse.
getAttachmentName()Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.
setAttachmentName(String value)Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.
close()Close object instance
dispose()Close object instance This method is obsolete, use close() instead.

FormEditor()

public FormEditor()

Constructor for FormEditor.


FormEditor formEditor = new FormEditor();

FormEditor(IDocument document)

public FormEditor(IDocument document)

Initializes new FormEditor object on base of the document .

Parameters:

ParameterTypeDescription
documentIDocumentPdf document.

FormEditor(IDocument document, OutputStream destStream)

public FormEditor(IDocument document, OutputStream destStream)

Initializes new FormEditor object on base of the document .

Parameters:

ParameterTypeDescription
documentIDocumentPdf document.
destStreamjava.io.OutputStreamDestination stream.

FormEditor(IDocument document, String destFileName)

public FormEditor(IDocument document, String destFileName)

Initializes new FormEditor object on base of the document .

Parameters:

ParameterTypeDescription
documentIDocumentPdf document.
destFileNamejava.lang.StringPath of the destination file.

FormEditor(InputStream srcStream, OutputStream destStream)

public FormEditor(InputStream srcStream, OutputStream destStream)

Constructor for FormEditor.


FormEditor formEditor = new FormEditor(new FileInputStream("InFile.pdf"), new FileOutputStream("OutFile.pdf"));

Parameters:

ParameterTypeDescription
srcStreamjava.io.InputStreamSource stream.
destStreamjava.io.OutputStreamDestination stream.

FormEditor(String srcFileName, String destFileName)

public FormEditor(String srcFileName, String destFileName)

Constructor for FormEditor


FormEditor formEditor = new FormEditor("InFile.pdf", "OutFile.pdf");

Parameters:

ParameterTypeDescription
srcFileNamejava.lang.StringName of source file.
destFileNamejava.lang.StringName of destination file.

getSrcFileName()

public String getSrcFileName()

Gets name of source file.

Returns: java.lang.String - string object

setSrcFileName(String value)

public void setSrcFileName(String value)

Sets name of source file.


FormEditor editor = new FormEditor();
 editor.setSrcFileName("InputFile.pdf");

Parameters:

ParameterTypeDescription
valuejava.lang.Stringstring object

getDestFileName()

public String getDestFileName()

Gets destination file name.

Returns: java.lang.String - string object

setDestFileName(String value)

public void setDestFileName(String value)

Sets destination file name.


FormEditor editor = new FormEditor();
 editor.setDestFileName("OutFile.pdf");

Parameters:

ParameterTypeDescription
valuejava.lang.Stringstring object

getSrcStream()

public InputStream getSrcStream()

Gets source stream.

Returns: java.io.InputStream - InputStream object

setSrcStream(InputStream value)

public void setSrcStream(InputStream value)

Sets source stream.


FormEditor editor = new FormEditor();
 editor.setSrcStream(new FileInputStream("InFile.pdf"));

Parameters:

ParameterTypeDescription
valuejava.io.InputStreamInputStream object

setConvertTo(PdfFormat value)

public void setConvertTo(PdfFormat value)

Sets PdfFormat PDF file format. Result file will be saved in specified file format. If this property is not specified then file will be save in default PDF format without conversion.

Parameters:

ParameterTypeDescription
valuePdfFormatPdfFormat element

getDestStream()

public OutputStream getDestStream()

Gets destination stream.


FormEditor editor = new FormEditor();
 editor.setDestStream(new FileInputStream("OutFile.pdf"));

Returns: java.io.OutputStream - OutputStream object

setDestStream(OutputStream value)

public void setDestStream(OutputStream value)

Sets destination stream.


FormEditor editor = new FormEditor();
 editor.setDestStream(new FileInputStream("OutFile.pdf"));

Parameters:

ParameterTypeDescription
valuejava.io.OutputStreamOutputStream object

getItems()

public String[] getItems()

Get Items which will be added to newly created list box or combo box.

Returns: java.lang.String[] - String[] object

setItems(String[] value)

public void setItems(String[] value)

Sets items which will be added to newly created list box or combo box.


formEditor = new com.aspose.pdf.facadesFormEditor("input.pdf", "output.pdf");
 formEditor.setItems(new String[]
 { "AAA", "BBB", "CCC" });
 formEditor.addField(FieldType.ListBox, "AddedListBoxField", "BBB", 1, 10, 30, 110, 130);
 formEditor.save();

Parameters:

ParameterTypeDescription
valuejava.lang.String[]String[] object

getExportItems()

public String[][] getExportItems()

Gets options for combo box with export values.


Returns: java.lang.String[][] - String[][] object

setExportItems(String[][] value)

public void setExportItems(String[][] value)

Sets options for combo box with export values.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "PdfForm_Updated.pdf"));
 formEditor.setExportItems ( new String[][]
 {
     new String[] { "1", "Firs" },
     new String[] { "2", "Second" },
     new String[] { "3", "Third" }
 });
 formEditor.addField(FieldType.ListBox, "AddedListBoxField", "Second", 1, 10, 30, 110, 130);
 formEditor.save();

Parameters:

ParameterTypeDescription
valuejava.lang.String[][]String[][] object

getFacade()

public FormFieldFacade getFacade()

Gets visual attributes of the field.

Returns: FormFieldFacade - FormFieldFacade object

setFacade(FormFieldFacade value)

public void setFacade(FormFieldFacade value)

Sets visual attributes of the field.


FormEditor fe = new FormEditor("PdfForm.pdf", "PdfForm_DecorateField_text.pdf");
 fe.setFacade(new FormFieldFacade());
 fe.getFacade().setBackgroundColor(Color.red);
 fe.getFacade().setTextColor(Color.blue);
 fe.getFacade().setBorderColor(Color.green);
 fe.getFacade().setAlignment(FormFieldFacade.AlignCenter);
 fe.setDecorateField("textField");
 fe.save();

Parameters:

ParameterTypeDescription
valueFormFieldFacadeFormFieldFacade object

getRadioGap()

public float getRadioGap()

Get the member to record the gap between two neighboring radio buttons in pixels,default is 50.

Returns: float - float value

setRadioGap(float value)

public void setRadioGap(float value)

Set the member to record the gap between two neighboring radio buttons in pixels,default is 50.


formEditor = new com.aspose.pdf.facades.FormEditor("PdfForm.pdf", "FormEditor_AddField_RadioButton.pdf");
 formEditor.setRadioGap(4);
 formEditor.setRadioHoriz(false);
 formEditor.setItems(new String[]
 { "First", "Second", "Third" });
 formEditor.addField(FieldType.Radio, "AddedRadioButtonField", "Second", 1, 10, 30, 110, 130);
 formEditor.save();

Parameters:

ParameterTypeDescription
valuefloatfloat value

getRadioHoriz()

public boolean getRadioHoriz()

Get the flag to indicate whether the radios are arranged horizontally or vertically, default value is true.

Returns: boolean - boolean value

setRadioHoriz(boolean value)

public void setRadioHoriz(boolean value)

Set the flag to indicate whether the radios are arranged horizontally or vertically, default value is true.


formEditor = new com.aspose.pdf.facades.FormEditor("PdfForm.pdf", "FormEditor_AddField_RadioButton.pdf");
 formEditor.setRadioGap(4);
 formEditor.setRadioHoriz(false);
 formEditor.setItems(new String[]
 { "First", "Second", "Third" });
 formEditor.addField(FieldType.Radio, "AddedRadioButtonField", "Second", 1, 10, 30, 110, 130);
 formEditor.save();

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getRadioButtonItemSize()

public double getRadioButtonItemSize()

Gets or sets size of radio button item size (when new radio button field is added).

FormEditor formEditor = new com.aspose.pdf.facades.FormEditor("PdfForm.pdf", "FormEditor_AddField_RadioButton.pdf");
 formEditor.setRadioGap(4);
 formEditor.setRadioHoriz(false);
 formEditor.setRadioButtonItemSize(20);
 formEditor.setItems(new String[]
 { "First", "Second", "Third" });
 formEditor.addField(com.aspose.pdf.facades.FieldType.Radio, "AddedRadioButtonField", "Second", 1, 10, 30, 110, 130);
 formEditor.save();

Returns: double - double value

setRadioButtonItemSize(double value)

public void setRadioButtonItemSize(double value)

Gets or sets size of radio button item size (when new radio button field is added).

FormEditor formEditor = new com.aspose.pdf.facades.FormEditor("PdfForm.pdf", "FormEditor_AddField_RadioButton.pdf");
 formEditor.setRadioGap(4);
 formEditor.setRadioHoriz(false);
 formEditor.setRadioButtonItemSize(20);
 formEditor.setItems(new String[]
 { "First", "Second", "Third" });
 formEditor.addField(com.aspose.pdf.facades.FieldType.Radio, "AddedRadioButtonField", "Second", 1, 10, 30, 110, 130);
 formEditor.save();

Parameters:

ParameterTypeDescription
valuedoubledouble value

getSubmitFlag()

public SubmitFormFlag getSubmitFlag()

Get the submit button’s submission flags

Returns: SubmitFormFlag - SubmitFormFlag element

setSubmitFlag(SubmitFormFlag value)

public void setSubmitFlag(SubmitFormFlag value)

Set the submit button’s submission flags

Parameters:

ParameterTypeDescription
valueSubmitFormFlagSubmitFormFlag element

save()

public void save()

Saves changes into destination file.

setFieldAttribute(String fieldName, int flag)

public boolean setFieldAttribute(String fieldName, int flag)

Set attributes of field.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "PdfForm_SetFieldAttribute.pdf");
 formEditor.setFieldAttribute("listboxField", PropertyFlag.ReadOnly);
 formEditor.setFieldAttribute("textField", PropertyFlag.NoExport);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of field which attributes should be set.
flagintFlag (NoExport/ReadOnly/Required)

Returns: boolean - true if attribute was set successfully.

setFieldAppearance(String fieldName, int flags)

public boolean setFieldAppearance(String fieldName, int flags)

Set field flags


FormEditor formEditor = new FormEditor("PdfForm1.pdf", "FormEditor_SetFieldAppearance.pdf");
 formEditor.setFieldAppearance("Name", AnnotationFlags.Hidden);
 formEditor.setFieldAppearance("Phone", AnnotationFlags.NoView | AnnotationFlags.Print);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of field whose flags should be updated.
flagsintFlag of the field.

Returns: boolean - true if flags were updated successfully.

setSubmitFlag(String fieldName, SubmitFormFlag submitFormFlag)

public boolean setSubmitFlag(String fieldName, SubmitFormFlag submitFormFlag)

Set submit flag of submit button.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_SetSubmitFlag.pdf");
 formEditor.setSubmitFlag("btnSubmit", SubmitFormFlag.Fdf);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of submit button.
submitFormFlagSubmitFormFlagSubmit flag.

Returns: boolean - boolean value

setSubmitUrl(String fieldName, String url)

public boolean setSubmitUrl(String fieldName, String url)

Sets URL of the button.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_SetSubmitUrl.pdf");
 formEditor.setSubmitUrl("btnSubmit", "www.mysite.com");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringSubmit button name.
urljava.lang.StringFully qualified URL.

Returns: boolean - boolean value

setFieldLimit(String fieldName, int fieldLimit)

public boolean setFieldLimit(String fieldName, int fieldLimit)

Sets maximum character count of the text field.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_SetFieldLimit.pdf");
 formEditor.setFieldLimit("textField", 15);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of the text field.
fieldLimitintNew value of limit for the field.

Returns: boolean - true if field limit was successfully set.

setFieldCombNumber(String fieldName, int combNumber)

public boolean setFieldCombNumber(String fieldName, int combNumber)

Sets number of combs for a regular single-line text field (the field is automatically divided into as many equally spaced positions, or combs, as the value of combNumber parameter).


FormEditor formEditor = new FormEditor("PdfWithAcroForm.pdf", "FormEditor_SetFieldComb.pdf"));
 formEditor.setFieldCombNumber("textCombField", 5);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe qualified field name.
combNumberintThe number of combs to divide the field into.

Returns: boolean - If success, return true;else false.

moveField(String fieldName, float llx, float lly, float urx, float ury)

public boolean moveField(String fieldName, float llx, float lly, float urx, float ury)

Set new position of field.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_MoveField.pdf");
 formEditor.moveField("textField", 20.5f, 20.3f, 120.6f, 40.8f);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of field which must be moved.
llxfloatAbscissa of the lower-left corner of the field.
llyfloatOrdinate of the lower-left coerner of the field.
urxfloatAbscissa of the upper-right corner of the field.
uryfloatOrdinate of the upper-right corner of the field.

Returns: boolean - true if field position was changed successfully.

addField(FieldType fieldType, String fieldName, int pageNum, float llx, float lly, float urx, float ury)

public boolean addField(FieldType fieldType, String fieldName, int pageNum, float llx, float lly, float urx, float ury)

Add field of specified type to the form.


FormEditor formEditor = new com.aspose.pdf.facades.FormEditor("PdfForm.pdf", "FormEditor_AddField_Text.pdf");
 formEditor.addField(FieldType.Text, "AddedTextField", 1, 10, 30, 110, 46);
 formEditor.save();

Parameters:

ParameterTypeDescription
fieldTypeFieldTypeType of the field which must be added.
fieldNamejava.lang.StringName of the field whic must be added.
pageNumintPage number where new field must be placed.
llxfloatAbscissa of the lower-left corner of the field.
llyfloatOrdinate of the lower-left corner of the field.
urxfloatAbscissa of the upper-right corner of the field.
uryfloatOrdinate of the upper-right corner of the field.

Returns: boolean - true if field was successfully added.

addField(FieldType fieldType, String fieldName, String initValue, int pageNum, float llx, float lly, float urx, float ury)

public boolean addField(FieldType fieldType, String fieldName, String initValue, int pageNum, float llx, float lly, float urx, float ury)

Add field of specified type to the form.

Parameters:

ParameterTypeDescription
fieldTypeFieldTypeType of the field which must be added.
fieldNamejava.lang.StringName of the field whic must be added.
initValuejava.lang.StringInitial value of the field.
pageNumintPage number where new field must be placed.
llxfloatAbscissa of the lower-left corner of the field.
llyfloatOrdinate of the lower-left corner of the field.
urxfloatAbscissa of the upper-right corner of the field.
uryfloatOrdinate of the upper-right corner of the field.

Returns: boolean - true if field was successfully added.

removeField(String fieldName)

public void removeField(String fieldName)

Remove field from the form.


FormEditr formEditor = new FormEditor("PdfForm.pdf", "FormEditor_RemoveField.pdf");
 formEditor.removeField("listboxField");
 formEditor.removeField("textField");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of the field which must be removed.

resetFacade()

public void resetFacade()

Reset all visual attribtues to empty value.

resetInnerFacade()

public void resetInnerFacade()

Reset all visual attribtues of inner facade to empty value.

copyInnerField(String fieldName, String newFieldName, int pageNum)

public void copyInnerField(String fieldName, String newFieldName, int pageNum)

Copies an existing field to the same position in specified page number. A new document will be produced, which contains everything the source document has except for the newly copied field.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringString value
newFieldNamejava.lang.StringString value
pageNumintint value

copyInnerField(String fieldName, String newFieldName, int pageNum, float abscissa, float ordinate)

public void copyInnerField(String fieldName, String newFieldName, int pageNum, float abscissa, float ordinate)

Copies an existing field to a new position specified by both page number and ordinates. A new document will be produced, which contains everything the source document has except for the newly copied field.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringString value
newFieldNamejava.lang.StringString value
pageNumintint value
abscissafloatfloat value
ordinatefloatfloat value

copyOuterField(String srcFileName, String fieldName)

public void copyOuterField(String srcFileName, String fieldName)

Copies an existing field from one PDF document to another document with original page number and ordinates. Notice: Only for AcroForm fields (excluding radio box).

Parameters:

ParameterTypeDescription
srcFileNamejava.lang.StringString value
fieldNamejava.lang.StringString value

copyOuterField(String srcFileName, String fieldName, int pageNum)

public void copyOuterField(String srcFileName, String fieldName, int pageNum)

Copies an existing field from one PDF document to another document with specified page number and original ordinates. Notice: Only for AcroForm fields (excluding radio box).

Parameters:

ParameterTypeDescription
srcFileNamejava.lang.StringString value
fieldNamejava.lang.StringString value
pageNumintint value

copyOuterField(String srcFileName, String fieldName, int pageNum, float abscissa, float ordinate)

public void copyOuterField(String srcFileName, String fieldName, int pageNum, float abscissa, float ordinate)

Copies an existing field from one PDF document to another document with specified page number and ordinates. Notice: Only for AcroForm fields (excluding radio box).

Parameters:

ParameterTypeDescription
srcFileNamejava.lang.StringString value
fieldNamejava.lang.StringString value
pageNumintint value
abscissafloatfloat value
ordinatefloatfloat value

decorateField(String fieldName)

public void decorateField(String fieldName)

Changes visual attributes of the specified field.


FormEditor fe = new FormEditor("PdfWithAcroForm.pdf", "FormEditor_DecorateField_text.pdf");
 fe.Facade = new FormFieldFacade();
 fe.Facade.setBackgroundColor(Color.Red);
 fe.Facade.setTextColor(Color.Blue);
 fe.Facade.setBorderColor(Color.Green);
 fe.Facade.setAlignment(FormFieldFacade.AlignCenter);
 fe.decorateField("textField");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name.

decorateField(FieldType fieldType)

public void decorateField(FieldType fieldType)

Changes visual attributes of all fields with the specified field type.


FormEditor fe = new FormEditor("PdfForm.pdf", "FormEditor_DecorateField.pdf");
 fe.setFacade(new FormFieldFacade());
 fe.getFacade().setBackgroundColor(Color.red);
 fe.getFacade().setTextColor(Color.blue);
 fe.getFacade().setBorderColor(Color.green);
 fe.getFacade().setAlignment(FormFieldFacade.AlignRight);
 // decorate all text fields.
 fe.decorateField(FieldType.Text);

Parameters:

ParameterTypeDescription
fieldTypeFieldTypeType of fields which will be decorated.

decorateField()

public void decorateField()

Changes visual attributes of all fields in the PDF document.


FormEditor fe = new FormEditor("PdfForm.pdf", "FormEditor_DecorateField.pdf");
 fe.setFacade(new FormFieldFacade());
 fe.getFacade().setBackgroundColor(Color.red);
 fe.getFacade().setTextColor(Color.blue);
 fe.getFacade().setBorderColor(Color.Green);
 fe.getFacade().setAlignment(FormFieldFacade.AlignRight);
 // decorate all fields.
 fe.decorateField();

renameField(String fieldName, String newFieldName)

public void renameField(String fieldName, String newFieldName)

Change name of the field.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "PdfForm_updated.pdf");
 formEditor.renameField("textField", "textField_Renamed");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringOld name of the field.
newFieldNamejava.lang.StringNew name of the field.

removeFieldAction(String fieldName)

public void removeFieldAction(String fieldName)

Remove submit action of the field.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_RemoveFieldAction.pdf");
 formEditor.removeFieldAction("btnSubmit");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of the field.

addSubmitBtn(String fieldName, int page, String label, String url, float llx, float lly, float urx, float ury)

public void addSubmitBtn(String fieldName, int page, String label, String url, float llx, float lly, float urx, float ury)

Add submit button on the form.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_AddSubmitBtn.pdf");
 formEditor.addSubmitBtn("submit", 1, "Submit", "www.check.com", 10, 200, 70, 270);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of new button.
pageintPage where button will be placed.
labeljava.lang.StringButton caption.
urljava.lang.StringURL of the submit button.
llxfloatAbscissa of the lower-left corner.
llyfloatOrdinate of the lower-left corner.
urxfloatAbscissa of the upper-right corner.
uryfloatOrdinate of the upper-right corner.

addListItem(String fieldName, String itemName)

public void addListItem(String fieldName, String itemName)

Adds new item to the list box.


FormEditor formEditor = new FormEditor("PdfForm.pdf", PdfForm_out.pdf");
 formEditor.addListItem("listBoxField", "Item 4 (New Item)");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of the field ot which new item will be added.
itemNamejava.lang.StringName if new item.

addListItem(String fieldName, String[] exportName)

public void addListItem(String fieldName, String[] exportName)

Add a new item with Export value to the existing list box field, only for AcroForm combo box field.


FormEditor fe = new FormEditor("PdfForm.pdf", "FormEditor_AddListItem2.pdf");
 fe.addListItem("listboxField", new String[]
 { "4", "Item4(Added)" });

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of field to which items will be added.
exportNamejava.lang.String[]A String array denoting a new list item with Export Value, i.e. (Item Label, Export Value).

delListItem(String fieldName, String itemName)

public void delListItem(String fieldName, String itemName)

Delete item from the list field.


formEditor = new com.aspose.pdf.facades.FormEditor("PdfForm.pdf", "FormEditor_DelListItem.pdf");
 formEditor.delListItem("listboxField", "item2");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of the field.
itemNamejava.lang.StringName of the item which must be deleted.

setFieldScript(String fieldName, String script)

public boolean setFieldScript(String fieldName, String script)

Set JavaScript for a PushButton field. If old JavaScript existed, it will be replaced by the new one.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name.
scriptjava.lang.StringThe Java script to be added/placed into a push button field.

Returns: boolean

single2Multiple(String fieldName)

public boolean single2Multiple(String fieldName)

Change a single-lined text field to a multiple-lined one.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "PdfForm_updated.pdf");
 formEditor.single2Multiple("textField");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe qualified field name.

Returns: boolean - If success, return true;else false.

setFieldAlignment(String fieldName, int alignment)

public boolean setFieldAlignment(String fieldName, int alignment)

Set the alignment style of a text field.


FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_updated.pdf"));
  formEditor.setFieldAlignment(fieldName, FormFieldFacade.AlignCenter);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe qualified field name.
alignmentintThe alignment style definition, including FormFieldFacade.AlignLeft, FormFieldFacade.AlignCenter and FormFieldFacade.AlignRight.

Returns: boolean

setFieldAlignmentV(String fieldName, int alignment)

public boolean setFieldAlignmentV(String fieldName, int alignment)

Set the vertical alignment style of a text field.


FormEditor fe = new FormEditor("PdfStaticForm.pdf", "VerticalAlign.pdf");
 fe.setFieldAlignmentV("form1[0].TextField[0]", FormFieldFacade.AlignBottom);

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe qualified field name.
alignmentintThe alignment style definition, including FormFieldFacade.AlignTop, FormFieldFacade.AlignMiddle and FormFieldFacade.AlignRight.

Returns: boolean

getDocument()

public IDocument getDocument()

Gets the document FormEditor is working on.

Returns: IDocument - IDocument object

getContentDisposition()

public int getContentDisposition()

Gets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

Returns: int - ContentDisposition element

setContentDisposition(int value)

public void setContentDisposition(int value)

Sets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

Parameters:

ParameterTypeDescription
valueintContentDisposition element

getSaveOptions()

public SaveOptions getSaveOptions()

Gets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

Returns: SaveOptions - SaveOptions object

setSaveOptions(SaveOptions value)

public void setSaveOptions(SaveOptions value)

Sets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

Parameters:

ParameterTypeDescription
valueSaveOptionsSaveOptions object

getAttachmentName()

public String getAttachmentName()

Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.

Returns: java.lang.String - String object

setAttachmentName(String value)

public void setAttachmentName(String value)

Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.

Parameters:

ParameterTypeDescription
valuejava.lang.StringString object

close()

public void close()

Close object instance

dispose()

public void dispose()

Close object instance This method is obsolete, use close() instead.