Javascript: FormFieldCollection.addTextFormField Method
Description
Adds a new TextFormField.
Syntax
<void> FormFieldCollection.addTextFormField(<Number> emptyWidth, [<RequestTextFormFieldCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| emptyWidth | Specifies the horizontal extension, in twips, of the TextFormField, when there is no text. When this parameter is set to 0, a default value is used. |
| callback | Optional. Receives the added TextFormField. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates FormFieldCollection.addTextFormField in a practical document-editing workflow. It adds a new TextFormField.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const formFields = mainText.formFields;
formFields.addTextFormField(
1440,
function(textFormField) {
if (!textFormField) {
console.warn("No text form field was returned.");
return;
}
console.log("add text form field result:", textFormField);
},
onTxError
);
}, onTxError);