# Javascript: TXTextControl.loadDocument Method

> Loads text in a certain format. The complete contents of the web editor are replaced.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 23.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: TXTextControl.loadDocument Method
- **688 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/loaddocument-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/loaddocument-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/loaddocument-method/llms-full.txt

---

### Description

Loads text in a certain format. The complete contents of the web editor are replaced.

### Syntax

```javascript
<void> TXTextControl.loadDocument(<StreamType> streamType, <string> base64Data, <LoadDocumentCallback> callback, [<LoadSettings> loadSettings], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| streamType | Specifies one of the numerical [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/streamtype-enumeration/llms-full.txt) values. |
| base64Data | Base64 encoded document data. For encoding strings containing characters outside of the Latin1 range use [TXTextControl.btoaUTF8](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/btoautf8-method/llms-full.txt). |
| callback | Receives information about the loaded data when the loading is finished. |
| loadSettings | Optional. Additional settings for loading the data. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example shows how to load a short unicode HTML snippet into the web editor.

```javascript
var html = "<h3>This is some <em>HTML</em> text. Стоял он, дум великих полн, И вдаль глядел.</h3>";
var encoded = TXTextControl.btoaUTF8(html);
TXTextControl.loadDocument(TXTextControl.StreamType.HTMLFormat, encoded);
```

The following example demonstrates `TXTextControl.loadDocument` in a practical document-editing workflow. It loads text in a certain format. The complete contents of the web editor are replaced.

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

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

---

## Nearby

- **Previous:** [Javascript: TXTextControl.load Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/load-method/llms-full.txt)
- **Next:** [Javascript: TXTextControl.loadJsonData Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/loadjsondata-method/llms-full.txt)
