# Javascript: TXTextControl.appendDocument Method

> Appends text in a certain format to the current document.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 25.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TXTextControl.appendDocument Method
- **378 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/appenddocument-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/appenddocument-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/appenddocument-method/llms-full.txt

---

### Description

Appends text in a certain format to the current document.

### Syntax

```javascript
<void> TXTextControl.appendDocument(<StreamType> streamType, <string> base64Data)
```

### Parameters

| Parameter | Description |
|---|---|
| streamType | Specifies one of the numerical [StreamType](https://docs.textcontrol.com/ds-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/ds-server/reference/javascript/txtextcontrol/btoautf8-method/llms-full.txt). |

### Examples

The following example shows how to append a short HTML snippet to the current document in the web editor.

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

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

```javascript
TXTextControl.appendDocument(
    TXTextControl.StreamType.HTMLFormat,
    "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgAH/qbPzWQAAAABJRU5ErkJggg=="
);
```

---

## Nearby

- **Previous:** [Javascript: TXTextControl.append Method](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/append-method/llms-full.txt)
- **Next:** [Javascript: TXTextControl.AppendSettings Enumeration](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/appendsettings-enumeration/llms-full.txt)
