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

NameTypeAccessDescription
documentDocumentReadReturns the bound document.
fieldNamesString[]ReadReturns the names of all form fields in the document.
facadeFormFieldFacadeReadReturns the visual-style facade applied to subsequently-created fields.

Methods

SignatureDescription
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)boolean7-arg {@link #addField} overload (no initial value).
FormEditor(document: Document)Creates a new editor bound to the specified document.
bindPdf(inputFile: String)booleanBinds a PDF file to this editor.
bindPdf(inputStream: InputStream)booleanBinds a PDF from an input stream.
bindPdf(document: Document)booleanBinds an existing {@link Document} to this editor.
getDocument()DocumentReturns the bound document.
getFieldNames()String[]Returns the names of all form fields in the document.
fillField(fieldName: String, value: String)booleanFills a form field with the specified value.
fillField(fieldName: String, value: boolean)booleanFills a checkbox-like field using a boolean value.
getField(fieldName: String)StringReturns the current value of a field.
flattenAllFields()booleanFlattens all form fields, making them non-interactive.
flattenField(fieldName: String)booleanFlattens a single field and removes it from the interactive form.
copyOuterField(sourceFile: String, fieldName: String, pageNumber: int)booleanCopies a named field from {@code sourceFile} into the bound document
onto {@code pageNumber}.
getFacade()FormFieldFacadeReturns 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)booleanAdds 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)booleanCreates a push button on {@code pageNumber} that submits the form to
{@code url} when activated.
addListItem(fieldName: String, item: String)booleanAdds an option to an existing list-box or combo-box field.
removeField(fieldName: String)booleanRemoves a form field by name.
getFieldType(fieldName: String)StringReturns the type of the specified field.
setFieldLimit(fieldName: String, limit: int)booleanSets the maximum text length for a text box field.
getFieldLimit(fieldName: String)intReturns the maximum text length for a text box field.
save()booleanSaves the bound document to the output file supplied via the
{@link #FormEditor(String, String)} constructor.
save(outputFile: String)booleanSaves the bound document to a file.
save(outputStream: OutputStream)booleanSaves the bound document to an output stream.
close()Closes the editor and releases the bound document.

See Also