# TextPart Object

> Represents a part of the document, which can be the main text, a header or footer or a text frame. The callback function argument for the getTextParts function.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Object
- **Introduced:** 24.0
- **Path:** DS Server > Reference > JavaScript API > TextPart Object
- **827 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/llms-full.txt

---

### Description

Represents a part of the document, which can be the main text, a header or footer or a text frame. The callback function argument for the [getTextParts](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/gettextparts-method/llms-full.txt) function.

### Syntax

```javascript
TextPart
```

### Examples

The following example demonstrates `TextPart` in a practical document-editing workflow. It represents a part of the document, which can be the main text, a header or footer or a text frame. The callback function argument for the getTextParts function.

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

TXTextControl.textParts.getMainText(function(textPart) {
    textPart.getID(
        function(result) {
            console.log("get id result:", result);
        },
        onTxError
    );
}, onTxError);
```

---

## In This Section

- [Javascript: TextPart.addSubTextPart Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/addsubtextpart-method/llms-full.txt): Obsolete. This method will be removed in one of the next versions. Inserts a new SubTextPart into the TextPart at the current input position.
- [Javascript: TextPart.addTextField Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/addtextfield-method/llms-full.txt): Obsolete. This method will be removed in one of the next versions. Inserts a new ApplicationField or TextField into the TextPart at the current input position.
- [Javascript: TextPart.getSubTextParts Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/getsubtextparts-method/llms-full.txt): Obsolete. This method will be removed in one of the next versions. Requests a collection of either all subtextparts the current text part contains or only the subtextpart containing the input position from the server and returns the collection by calling a callback function which has to be provided as a parameter to the function.
- [Javascript: TextPart.getTextFields Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/gettextfields-method/llms-full.txt): Obsolete. This method will be removed in one of the next versions. Requests a collection of either all text fields in the text part or only the text field containing the input position from the server and returns the collection by calling a callback function which has to be provided as a parameter to the function.
- [Javascript: TextPart.index Property](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/index-property/llms-full.txt): Obsolete. This property will be removed in one of the next versions. The 0-based index of the text part.
- [Javascript: TextPart.removeSubTextPart Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/removesubtextpart-method/llms-full.txt): Obsolete. This method will be removed in one of the next versions. Removes a SubTextPart from the TextPart.
- [Javascript: TextPart.selection Property](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/selection-property/llms-full.txt): Obsolete. This property will be removed in one of the next versions. The getter returns an object of type Selection. The setter changes the selection to a given start position and a given length using an object of type SelectionBounds.
- [Javascript: TextPart.type Property](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/type-property/llms-full.txt): Obsolete. This property will be removed in one of the next versions. The Text part type. Possible values are "mainText", "headerFooter" and "textFrame".

---

## Nearby

- **Previous:** [Javascript: TextFrameEventArgs.textFrame Property](https://docs.textcontrol.com/ds-server/reference/javascript/textframeeventargs/textframe-property/llms-full.txt)
- **Next:** [Javascript: TextPart.addSubTextPart Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/addsubtextpart-method/llms-full.txt)
