# Javascript: ImageCollection.addInline Method

> Creates and inserts a new image inline, which means that it is treated in the text like a single character. The image is inserted at the specified text input position.

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

---

### Description

Creates and inserts a new image inline, which means that it is treated in the text like a single character. The image is inserted at the specified text input position.

### Syntax

```javascript
<void> ImageCollection.addInline(<string> imageData, <number> textPosition, [<RequestImageCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| imageData | The base64 encoded image data. |
| textPosition | Specifies the text position at which the barcode is to be inserted. If -1 is specified, the barcode is inserted at the current input position. |
| callback | Optional. The newly created image object is returned via this callback function. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example inserts a self-contained one-pixel PNG at the input position and gives it an accessible name.

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

const pixelPng = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";

TXTextControl.images.addInline(pixelPng, -1, function(image) {
    image.setName("Status indicator", function() {
        console.log("Inline image inserted and named.");
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: ImageCollection.addAtFixedPositionOnPage Method](https://docs.textcontrol.com/ds-server/reference/javascript/imagecollection/addatfixedpositiononpage-method/llms-full.txt)
- **Next:** [Javascript: ImageCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/imagecollection/getitem-method/llms-full.txt)
