Javascript: PageNumberFieldCollection.add Method
Description
Inserts a new page number field at the current input position which displays Arabic numbers starting with 1.
Syntax
<void> PageNumberFieldCollection.add([<RequestPageNumberFieldCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| callback | Optional. Receives the added PageNumberField. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates PageNumberFieldCollection.add in a practical document-editing workflow. It inserts a new page number field at the current input position which displays Arabic numbers starting with 1.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const pageNumberFields = mainText.pageNumberFields;
pageNumberFields.add(
function(field) {
if (!field) {
console.warn("No pagenumber field was returned.");
return;
}
console.log("add result:", field);
},
onTxError
);
}, onTxError);