FormEditor
Overview
FormEditor is a class in Aspose.Pdf FOSS for Java.
Provides methods for editing form fields in a PDF document: listing fields, filling values, flattening, and removing fields.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
document | Document | Read | Returns the bound document. |
fieldNames | String[] | Read | Returns the names of all form fields in the document. |
facade | FormFieldFacade | Read | Returns the visual-style facade applied to subsequently-created fields. |
Methods
| Signature | Description |
|---|---|
FormEditor() | Creates a new {@code FormEditor} instance. |
FormEditor(inputFile: String) | Creates a new editor bound to the specified file. |
FormEditor(inputFile: String, outputFile: String) | Creates a new editor bound to {@code inputFile} and configured to write |
| the result to {@code outputFile} when {@link #save()} is called. | |
FormEditor(document: Document, outputFile: String) | Creates a {@code FormEditor} bound to an already-loaded document and |
| configured to write the result to {@code outputFile} on {@link #save()}. | |
addField(type: FieldType, fieldName: String, pageNumber: int, llx: double, lly: double, urx: double, ury: double) → boolean | 7-arg {@link #addField} overload (no initial value). |
FormEditor(document: Document) | Creates a new editor bound to the specified document. |
bindPdf(inputFile: String) → boolean | Binds a PDF file to this editor. |
bindPdf(inputStream: InputStream) → boolean | Binds a PDF from an input stream. |
bindPdf(document: Document) → boolean | Binds an existing {@link Document} to this editor. |
getDocument() → Document | Returns the bound document. |
getFieldNames() → String[] | Returns the names of all form fields in the document. |
fillField(fieldName: String, value: String) → boolean | Fills a form field with the specified value. |
fillField(fieldName: String, value: boolean) → boolean | Fills a checkbox-like field using a boolean value. |
getField(fieldName: String) → String | Returns the current value of a field. |
flattenAllFields() → boolean | Flattens all form fields, making them non-interactive. |
flattenField(fieldName: String) → boolean | Flattens a single field and removes it from the interactive form. |
copyOuterField(sourceFile: String, fieldName: String, pageNumber: int) → boolean | Copies a named field from {@code sourceFile} into the bound document |
| onto {@code pageNumber}. | |
getFacade() → FormFieldFacade | Returns the visual-style facade applied to subsequently-created fields. |
setFacade(facade: FormFieldFacade) | Mirrors the C# property {@code FormEditor.Facade}: sets the visual-style |
| facade used by {@link #addField(FieldType, String, String, int, double, double, double, double)} | |
| to dress newly-created widget annotations (background colour, border style, etc.). | |
resetFacade() | Drops any previously-set facade so the next {@code addField} uses defaults. |
addField(type: FieldType, fieldName: String, value: String, pageNumber: int, llx: double, lly: double, urx: double, ury: double) → boolean | Adds a new form field to {@code pageNumber} at the given rectangle. |
addSubmitBtn(fieldName: String, pageNumber: int, caption: String, url: String, llx: double, lly: double, urx: double, ury: double) → boolean | Creates a push button on {@code pageNumber} that submits the form to |
| {@code url} when activated. | |
addListItem(fieldName: String, item: String) → boolean | Adds an option to an existing list-box or combo-box field. |
removeField(fieldName: String) → boolean | Removes a form field by name. |
getFieldType(fieldName: String) → String | Returns the type of the specified field. |
setFieldLimit(fieldName: String, limit: int) → boolean | Sets the maximum text length for a text box field. |
getFieldLimit(fieldName: String) → int | Returns the maximum text length for a text box field. |
save() → boolean | Saves the bound document to the output file supplied via the |
| {@link #FormEditor(String, String)} constructor. | |
save(outputFile: String) → boolean | Saves the bound document to a file. |
save(outputStream: OutputStream) → boolean | Saves the bound document to an output stream. |
close() | Closes the editor and releases the bound document. |