Paragraph Object
Description
A Paragraph object represents a single paragraph in a Text Control document. Paragraphs are numbered from the beginning to the end of the document beginning with 1. A document has at least one paragraph.
Syntax
ParagraphExamples
The following example demonstrates Paragraph in a practical document-editing workflow. A Paragraph object represents a single paragraph in a Text Control document. Paragraphs are numbered from the beginning to the end of the document beginning with 1. A document has at least one paragraph.
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.getText(
function(result) {
console.log("get text result:", result);
},
onTxError
);
}, onTxError);
}, onTxError);Members
Properties
| Property | Description |
|---|---|
| format | The paragraph's formatting attributes. |
| listFormat | The paragraph's bulleted or numbered list and/or its formatting attributes. |
Methods
| Method | Description |
|---|---|
| getFormattingStyle | Gets the paragraph's formatting style. |
| getLength | Gets the number of characters in the paragraph including the paragraph end character. |
| getLines | Gets the number of lines the paragraph consists of. |
| getListNumber | Gets the paragraph's list number. |
| getListNumberText | Gets the paragraph's list number text. The text consists of the text in front of the number, the number itself and the text behind the list number. It is an empty string, if the paragraph does not belong to a numbered list. |
| getStart | Gets the number (one-based) of the paragraph's first character. |
| getStartLine | Gets the number (one-based) of the paragraph's first line. |
| getText | Gets the paragraph's text. |
| save | Saves the paragraph in a certain format and sends the result back asynchronously by calling a given callback function. |
| select | Selects the paragraph. |
| setFormattingStyle | Sets the paragraph's formatting style. The specified style must be the name of a style contained in the ParagraphStyles collection of a Text Control document. |