Javascript: SubTextPartCollection.add Method
Description
Adds a new SubTextPart to the collection.
Syntax
<void> SubTextPartCollection.add(<String> name, <Number> id, <Number> start, <Number> length, [<AddSubTextPartCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| name | Specifies the name of the subtextpart. This parameter can be null or an empty string to indicate, that the subtextpart has no name. |
| id | Specifies an identifier for the subtextpart. This parameter can be 0 to indicate, that the subtextpart has no identifier. |
| start | Specifies the index (one-based) of the first character which belongs to the subtextpart. |
| length | Specifies the number of characters which belong to the subtextpart. |
| callback | Optional. Receives information about the result of the adding and the added subtextpart. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates SubTextPartCollection.add in a practical document-editing workflow. It adds a new SubTextPart to the collection.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const subTextParts = mainText.subTextParts;
subTextParts.add(
"InvoiceAddress",
25,
1,
5,
function(response, addResult) {
if (!response) {
console.warn("No sub text part callback data was returned.");
return;
}
console.log("add result:", response);
},
onTxError
);
}, onTxError);