Javascript: Paragraph.getLength Method
Description
Gets the number of characters in the paragraph including the paragraph end character.
Syntax
<void> Paragraph.getLength(<RequestNumberCallback> callback, [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| callback | Receives the number of characters in the paragraph including the paragraph end character. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates Paragraph.getLength in a practical document-editing workflow. It gets the number of characters in the paragraph including the paragraph end character.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const paragraphs = mainText.paragraphs;
paragraphs.getItem(function(paragraph) {
if (!paragraph) {
console.warn("No paragraph is available at the current input position.");
return;
}
paragraph.getLength(
function(result) {
console.log("get length result:", result);
},
onTxError
);
}, onTxError);
}, onTxError);