# Javascript: Paragraph.getLength Method

> Gets the number of characters in the paragraph including the paragraph end character.

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

---

### Description

Gets the number of characters in the paragraph including the paragraph end character.

### Syntax

```javascript
<void> Paragraph.getLength(<RequestNumberCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the number of characters in the paragraph including the paragraph end character. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `Paragraph.getLength` in a practical document-editing workflow. It gets the number of characters in the paragraph including the paragraph end character.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const paragraphs = mainText.paragraphs;
    paragraphs.getItem(function(paragraph) {
        if (!paragraph) {
            console.warn("No paragraph is available at the current input position.");
            return;
        }
    
        paragraph.getLength(
            function(result) {
                console.log("get length result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: Paragraph.getFormattingStyle Method](https://docs.textcontrol.com/ds-server/reference/javascript/paragraph/getformattingstyle-method/llms-full.txt)
- **Next:** [Javascript: Paragraph.getLines Method](https://docs.textcontrol.com/ds-server/reference/javascript/paragraph/getlines-method/llms-full.txt)
