public interface IFormEditor
Class for editing forms (adding/deleting field etc)
Modifier and Type | Method and Description |
---|---|
boolean |
addField(int fieldType,
String fieldName,
int pageNum,
float llx,
float lly,
float urx,
float ury)
Add field of specified type to the form.
|
boolean |
addField(int fieldType,
String fieldName,
String initValue,
int pageNum,
float llx,
float lly,
float urx,
float ury)
Add field of specified type to the form.
|
void |
addListItem(String fieldName,
String itemName)
Adds new item to the list box.
|
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.
|
void |
addSubmitBtn(String fieldName,
int page,
String label,
String url,
float llx,
float lly,
float urx,
float ury)
Add submit button on the form.
|
void |
close()
Closes object
|
void |
copyInnerField(String fieldName,
String newFieldName,
int pageNum)
Copies an existing field to the same position in specified page number.
|
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.
|
void |
copyOuterField(String srcFileName,
String fieldName)
Copies an existing field from one PDF document to another document with original page number
and ordinates.
|
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.
|
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.
|
void |
decorateField()
Changes visual attributes of all fields in the PDF document.
|
void |
decorateField(int fieldType)
Changes visual attributes of all fields with the specified field type.
|
void |
decorateField(String fieldName)
Changes visual attributes of the specified field.
|
void |
delListItem(String fieldName,
String itemName)
Delete item from the list field.
|
void |
dispose()
Closes object
|
String |
getAttachmentName()
Gets name of attachment when result of operation is stored into HttpResponse objects as
attachment.
|
int |
getContentDisposition()
Gets how content will be stored when result of operation is stored into HttpResponse object.
|
String |
getDestFileName()
Gets destination file name.
|
OutputStream |
getDestStream()
Gets destination stream.
|
IDocument |
getDocument()
Gets the document
FormEditor is working on. |
String[][] |
getExportItems()
Gets options for combo box with export values.
|
FormFieldFacade |
getFacade()
Gets visual attributes of the field.
|
String[] |
getItems()
Returns item array
|
double |
getRadioButtonItemSize()
Gets or sets size of radio button item size (when new radio button field is added).
|
float |
getRadioGap()
Get the member to record the gap between two neighboring radio buttons in pixels,default is
50.
|
boolean |
getRadioHoriz()
Get the flag to indicate whether the radios are arranged horizontally or vertically, default
value is true.
|
SaveOptions |
getSaveOptions()
Gets save options when result is stored as HttpResponse.
|
String |
getSrcFileName()
Gets name of source file.
|
InputStream |
getSrcStream()
Gets source stream.
|
int |
getSubmitFlag()
Get the submit button's submission flags
|
boolean |
moveField(String fieldName,
float llx,
float lly,
float urx,
float ury)
Set new position of field.
|
void |
removeField(String fieldName)
Remove field from the form.
|
void |
removeFieldAction(String fieldName)
Remove submit action of the field.
|
void |
renameField(String fieldName,
String newFieldName)
Change name of the field.
|
void |
resetFacade()
Reset all visual attributes to empty value.
|
void |
resetInnerFacade()
Reset all visual attributes of inner facade to empty value.
|
void |
save()
Saves changes into destination file.
|
void |
setAttachmentName(String value)
Sets name of attachment when result of operation is stored into HttpResponse objects as
attachment.
|
void |
setContentDisposition(int value)
Sets how content will be stored when result of operation is stored into HttpResponse object.
|
void |
setConvertTo(int value)
Sets
PdfFormat PDF file format. |
void |
setDestFileName(String value)
Sets destination file name.
|
void |
setDestStream(OutputStream value)
Sets destination stream.
|
void |
setExportItems(String[][] value)
Sets options for combo box with export values.
|
void |
setFacade(FormFieldFacade value)
Sets visual attributes of the field.
|
boolean |
setFieldAlignment(String fieldName,
int alignment)
Set the alignment style of a text field.
|
boolean |
setFieldAlignmentV(String fieldName,
int alignment)
Set the vertical alignment style of a text field.
|
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);
|
boolean |
setFieldAttribute(String fieldName,
int flag)
Set attributes of field.
|
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).
|
boolean |
setFieldLimit(String fieldName,
int fieldLimit)
Sets maximum character count of the text field.
|
boolean |
setFieldScript(String fieldName,
String script)
Set JavaScript for a PushButton field.
|
void |
setItems(String[] value)
Sets items which will be added to newly created list box or combo box.
|
void |
setRadioButtonItemSize(double value)
Gets or sets size of radio button item size (when new radio button field is added).
|
void |
setRadioGap(float value)
Set the member to record the gap between two neighboring radio buttons in pixels,default is
50.
|
void |
setRadioHoriz(boolean value)
Set the flag to indicate whether the radios are arranged horizontally or vertically, default
value is true.
|
void |
setSaveOptions(SaveOptions value)
Sets save options when result is stored as HttpResponse.
|
void |
setSrcFileName(String value)
Sets name of source file.
|
void |
setSrcStream(InputStream value)
Sets source stream.
|
void |
setSubmitFlag(int value)
Set the submit button's submission flags
|
boolean |
setSubmitFlag(String fieldName,
int submitFormFlag)
Set submit flag of submit button.
|
boolean |
setSubmitUrl(String fieldName,
String url)
Sets URL of the button.
|
boolean |
single2Multiple(String fieldName)
Change a single-lined text field to a multiple-lined one.
|
String getSrcFileName()
Gets name of source file.
void setSrcFileName(String value)
Sets name of source file.
FormEditor editor = new FormEditor(); editor.setSrcFileName("InputFile.pdf");
value
- string valueString getDestFileName()
Gets destination file name.
void setDestFileName(String value)
Sets destination file name.
FormEditor editor = new FormEditor(); editor.setDestFileName("OutFile.pdf");
value
- String objectInputStream getSrcStream()
Gets source stream.
void setSrcStream(InputStream value)
Sets source stream.
FormEditor editor = new FormEditor(); editor.setSrcStream(new FileInputStream("InFile.pdf"));
value
- InputStream objectvoid setConvertTo(int 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.
value
- PdfFormat elementPdfFormat
OutputStream getDestStream()
Gets destination stream.
FormEditor editor = new FormEditor(); editor.setDestStream(new FileInputStream("OutFile.pdf"));
void setDestStream(OutputStream value)
Sets destination stream.
FormEditor editor = new FormEditor(); editor.setDestStream(new FileInputStream("OutFile.pdf"));
value
- OutputStream objectString[] getItems()
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();
value
- String[] objectString[][] getExportItems()
Gets options for combo box with export values.
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();
value
- String[][] objectFormFieldFacade getFacade()
Gets visual attributes of the field.
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();
value
- FormFieldFacade objectfloat getRadioGap()
Get the member to record the gap between two neighboring radio buttons in pixels,default is 50.
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();
value
- float valueboolean getRadioHoriz()
Get the flag to indicate whether the radios are arranged horizontally or vertically, default value is true.
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();
value
- boolean valuedouble 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();
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();
value
- double valueint getSubmitFlag()
Get the submit button's submission flags
SubmitFormFlag
void setSubmitFlag(int value)
Set the submit button's submission flags
value
- SubmitFormFlag elementSubmitFormFlag
void save()
Saves changes into destination file.
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);
fieldName
- Name of field which attributes should be set.flag
- Flag (NoExport/ReadOnly/Required)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);
fieldName
- Name of field whose flags should be updated.flags
- Flag of the field.boolean setSubmitFlag(String fieldName, int submitFormFlag)
Set submit flag of submit button.
FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_SetSubmitFlag.pdf"); formEditor.setSubmitFlag("btnSubmit", SubmitFormFlag.Fdf);
fieldName
- Name of submit button.submitFormFlag
- Submit flag.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");
fieldName
- Submit button name.url
- Fully qualified URL.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);
fieldName
- Name of the text field.fieldLimit
- New value of limit for the field.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);
fieldName
- The qualified field name.combNumber
- The number of combs to divide the field into.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);
fieldName
- Name of field which must be moved.llx
- Abscissa of the lower-left corner of the field.lly
- Ordinate of the lower-left corner of the field.urx
- Abscissa of the upper-right corner of the field.ury
- Ordinate of the upper-right corner of the field.boolean addField(int 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();
fieldType
- Type of the field which must be added.fieldName
- Name of the field which must be added.pageNum
- Page number where new field must be placed.llx
- Abscissa of the lower-left corner of the field.lly
- Ordinate of the lower-left corner of the field.urx
- Abscissa of the upper-right corner of the field.ury
- Ordinate of the upper-right corner of the field.boolean addField(int fieldType, String fieldName, String initValue, int pageNum, float llx, float lly, float urx, float ury)
Add field of specified type to the form.
fieldType
- Type of the field which must be added.fieldName
- Name of the field which must be added.initValue
- Initial value of the field.pageNum
- Page number where new field must be placed.llx
- Abscissa of the lower-left corner of the field.lly
- Ordinate of the lower-left corner of the field.urx
- Abscissa of the upper-right corner of the field.ury
- Ordinate of the upper-right corner of the field.void removeField(String fieldName)
Remove field from the form.
FormEditr formEditor = new FormEditor("PdfForm.pdf", "FormEditor_RemoveField.pdf"); formEditor.removeField("listboxField"); formEditor.removeField("textField");
fieldName
- Name of the field which must be removed.void resetFacade()
Reset all visual attributes to empty value.
void resetInnerFacade()
Reset all visual attributes of inner facade to empty value.
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.
fieldName
- String valuenewFieldName
- String valuepageNum
- int valuevoid 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.
fieldName
- String valuenewFieldName
- String valuepageNum
- int valueabscissa
- float valueordinate
- float valuevoid 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).
srcFileName
- String valuefieldName
- String valuevoid 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).
srcFileName
- String valuefieldName
- String valuepageNum
- int valuevoid 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).
srcFileName
- String valuefieldName
- String valuepageNum
- int valueabscissa
- float valueordinate
- float valuevoid 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");
fieldName
- The fully qualified field name.void decorateField(int 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);
fieldType
- Type of fields which will be decorated.FieldType
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();
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");
fieldName
- Old name of the field.newFieldName
- New name of the field.void removeFieldAction(String fieldName)
Remove submit action of the field.
FormEditor formEditor = new FormEditor("PdfForm.pdf", "FormEditor_RemoveFieldAction.pdf"); formEditor.removeFieldAction("btnSubmit");
fieldName
- Name of the field.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);
fieldName
- Name of new button.page
- Page where button will be placed.label
- Button caption.url
- URL of the submit button.llx
- Abscissa of the lower-left corner.lly
- Ordinate of the lower-left corner.urx
- Abscissa of the upper-right corner.ury
- Ordinate of the upper-right corner.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)");
fieldName
- Name of the field of which new item will be added.itemName
- Name if new item.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)" });
fieldName
- Name of field to which items will be added.exportName
- A String array denoting a new list item with Export Value, i.e. (Item Label, Export Value).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");
fieldName
- Name of the field.itemName
- Name of the item which must be deleted.boolean setFieldScript(String fieldName, String script)
Set JavaScript for a PushButton field. If old JavaScript existed, it will be replaced by the new one.
fieldName
- The fully qualified field name.script
- The Java script to be added/placed into a push button field.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");
fieldName
- The qualified field name.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);
fieldName
- The qualified field name.alignment
- The alignment style definition, including FormFieldFacade.AlignLeft,
FormFieldFacade.AlignCenter and FormFieldFacade.AlignRight.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);
fieldName
- The qualified field name.alignment
- The alignment style definition, including FormFieldFacade.AlignTop,
FormFieldFacade.AlignMiddle and FormFieldFacade.AlignRight.IDocument getDocument()
Gets the document FormEditor
is working on.
int getContentDisposition()
Gets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.
ContentDisposition
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.
value
- ContentDisposition elementContentDisposition
SaveOptions getSaveOptions()
Gets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.
void setSaveOptions(SaveOptions value)
Sets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.
value
- SaveOptions objectString getAttachmentName()
Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.
void setAttachmentName(String value)
Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.
value
- String objectvoid close()
void dispose()