DS Server

Paragraph Object

Object|Introduced in 28.0

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

Paragraph

Examples

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

PropertyDescription
formatThe paragraph's formatting attributes.
listFormatThe paragraph's bulleted or numbered list and/or its formatting attributes.

Methods

MethodDescription
getFormattingStyleGets the paragraph's formatting style.
getLengthGets the number of characters in the paragraph including the paragraph end character.
getLinesGets the number of lines the paragraph consists of.
getListNumberGets the paragraph's list number.
getListNumberTextGets 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.
getStartGets the number (one-based) of the paragraph's first character.
getStartLineGets the number (one-based) of the paragraph's first line.
getTextGets the paragraph's text.
saveSaves the paragraph in a certain format and sends the result back asynchronously by calling a given callback function.
selectSelects the paragraph.
setFormattingStyleSets 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.

Further Reading

  • Sample Code: Removing All Empty Paragraphs Completely –