# Javascript: TextCharCollection.add Method

> Inserts a character at the specified position using the specified font.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TextCharCollection.add Method
- **510 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textcharcollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textcharcollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textcharcollection/add-method/llms-full.txt

---

### Description

Inserts a character at the specified position using the specified font.

### Syntax

```javascript
<void> TextCharCollection.add(<string> character, <string> fontName, <number> textPosition, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| character | Specifies the character to insert. |
| fontName | Specifies the name of the font which is used for the specified character. |
| textPosition | Specifies a text input position. The first input position in a document is 0. |
| callback | Optional. Receives whether the character is succesfully inserted. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `TextCharCollection.add` in a practical document-editing workflow. It inserts a character at the specified position using the specified font.

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

function add(textChars) {
    textChars.add(
        "Quarterly report",
        "Arial",
        -1,
        function(result) {
            if (result) {
                console.log("add is available.");
            } else {
                console.warn("add is not available in the current document state.");
            }
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [TextCharCollection Object](https://docs.textcontrol.com/ds-server/reference/javascript/textcharcollection/llms-full.txt)
- **Next:** [Javascript: TextCharCollection.addControlChar Method](https://docs.textcontrol.com/ds-server/reference/javascript/textcharcollection/addcontrolchar-method/llms-full.txt)
