DS Server

Javascript: TXTextControl.append Method

Method|Introduced in 31.0

Description

Appends text to the document in a certain format.

Syntax

<void> TXTextControl.append(<StreamType> streamType, <string> base64Data, <LoadDocumentCallback> callback, <LoadSettings> loadSettings, <AppendSettings> appendSettings, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
streamType

Specifies one of the numerical StreamType values.

base64Data

Base64 encoded document data. For encoding strings containing characters outside of the Latin1 range use TXTextControl.btoaUTF8.

callback

Receives information about the appended data when the appending process is finished.

loadSettings

Additional settings for appending the data. Can be null.

appendSettings

Settings on how the document is appended.

errorCallback

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

Examples

The following example demonstrates TXTextControl.append in a practical document-editing workflow. Appends text to the document in a certain format.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.append(
    TXTextControl.StreamType.HTMLFormat,
    "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgAH/qbPzWQAAAABJRU5ErkJggg==",
    function(result) {
        if (!result) {
            console.warn("No load document callback data was returned.");
            return;
        }
        
        console.log("append result:", result);
    },
    { loadImages: true, loadHypertextLinks: true },
    TXTextControl.AppendSettings.StartWithNewParagraph,
    onTxError
);