TX Text Control .NET Server

Javascript: ParagraphCollection.getItem Method

Method|Introduced in 28.0

Description

Gets a particular Paragraph from the collection.

Syntax

<void> ParagraphCollection.getItem(<number> textPosition, <RequestParagraphCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
textPosition

Specifies a zero-based text position.

callback

Receives the particular Paragraph.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates ParagraphCollection.getItem in a practical document-editing workflow. It gets a particular Paragraph from the collection.

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(
        -1,
        function(result) {
            if (!result) {
                console.warn("No paragraph was returned.");
                return;
            }
            
            console.log("get item result:", result);
        },
        onTxError
    );
}, onTxError);