Javascript: PageNumberFieldCollection.getItem Method
Description
Gets the field at the current input position or null, if there is no such field at the current input position.
Syntax
<void> PageNumberFieldCollection.getItem(<RequestPageNumberFieldCallback> callback, [<ErrorCallback> errorCallback], [<number> id])Parameters
| Parameter | Description |
|---|---|
| callback | Receives the found PageNumberField. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| id | Optional. Specifies the page number field's identifier set with the ID property. The method returns null if a page number field with the specified identifier does not exist. |
Examples
The following example demonstrates PageNumberFieldCollection.getItem in a practical document-editing workflow. It gets the field at the current input position or null, if there is no such field at the current input position.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const pageNumberFields = mainText.pageNumberFields;
pageNumberFields.getItem(
function(field) {
if (!field) {
console.warn("No pagenumber field was returned.");
return;
}
console.log("get item result:", field);
},
onTxError,
25
);
}, onTxError);