TX Text Control .NET Server

Javascript: Paragraph.save Method

Method|Introduced in 28.0

Description

Saves the paragraph in a certain format and sends the result back asynchronously by calling a given callback function.

Syntax

<void> Paragraph.save(<StreamType> streamType, <SaveDocumentCallback> callback, [<SaveSettings> saveSettings], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
streamType

Specifies one of the StreamType values.

callback

Receives the paragraph's data in a certain format including additional information.

saveSettings

Optional. Specifies additional settings for saving.

errorCallback

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

Examples

The following example demonstrates Paragraph.save in a practical document-editing workflow. It saves the paragraph in a certain format and sends the result back asynchronously by calling a given callback function.

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.save(
            TXTextControl.StreamType.HTMLFormat,
            function(result) {
                if (!result) {
                    console.warn("No save document result was returned.");
                    return;
                }
                
                console.log("save result:", result);
            },
            { creatorApplication: "Document Editor sample" },
            onTxError
        );
    }, onTxError);
}, onTxError);