# Javascript: TextCharCollection.getItem Method

> Gets a particular character from the collection specified through a certain geometrical position.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: TextCharCollection.getItem Method
- **551 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textcharcollection/getitem-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textcharcollection/getitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textcharcollection/getitem-method/llms-full.txt

---

### Description

Gets a particular character from the collection specified through a certain geometrical position.

### Syntax

```javascript
<void> TextCharCollection.getItem(<Point> location, <boolean> getNearest, <RequestTextCharCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| location | Specifies the character's location. The point must be specified in pixels with an origin at the top left corner of the control. |
| getNearest | Specifies whether the nearest character is returned. If this parameter is set to true, the nearest character is returned. Otherwise, if set to false, a character is only returned, if the specified location is inside the bounding rectangle of an existing character. |
| callback | Receives the textchar at the certain geometrical position. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `TextCharCollection.getItem` in a practical document-editing workflow. It gets a particular character from the collection specified through a certain geometrical position.

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

function inspectItem(textChars) {
    textChars.getItem(
        { x: 1440, y: 720 },
        true,
        function(textChar) {
            if (!textChar) {
                console.warn("No text char was returned.");
                return;
            }
            
            console.log("get item result:", textChar);
        },
        onTxError
    );
}
```

---

## Nearby

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