# DocumentLink Object

> The DocumentLink object represents a text position in a Text Control document that is a target of a document link.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Object
- **Introduced:** 28.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > DocumentLink Object
- **2271 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/llms-full.txt

---

### Description

The DocumentLink object represents a text position in a Text Control document that is a target of a document link.

### Syntax

```javascript
DocumentLink
```

### Examples

The following example demonstrates `DocumentLink` in a practical document-editing workflow. The DocumentLink object represents a text position in a Text Control document that is a target of a document link.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const documentLinks = mainText.documentLinks;
    documentLinks.getItem(function(documentLink) {
        if (!documentLink) {
            console.warn("No document link is available at the current input position.");
            return;
        }
    
        documentLink.getAutoGenerationType(
            function(result) {
                console.log("get auto generation type result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## In This Section

- [Javascript: DocumentLink.getAutoGenerationType Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/getautogenerationtype-method/llms-full.txt): Gets the type of auto-generation. A document link in a table of contents is automatically generated when the table of contents is inserted into the document.
- [Javascript: DocumentLink.getDescriptiveText Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/getdescriptivetext-method/llms-full.txt): Gets the document link's descriptive text. An empty string indicates that the link has no such text.
- [Javascript: DocumentLink.getDocumentTarget Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/getdocumenttarget-method/llms-full.txt): Gets an object of the type DocumentTarget specifying to where the link points.
- [Javascript: DocumentLink.setDescriptiveText Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/setdescriptivetext-method/llms-full.txt): Sets the document link's descriptive text. An empty string or null can be used to delete a previously set text.
- [Javascript: DocumentLink.setDocumentTarget Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/setdocumenttarget-method/llms-full.txt): Sets an object of the type DocumentTarget specifying to where the link points.

---

## Nearby

- **Previous:** [Javascript: DocumentEditorSettings.webSocketProtocols Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenteditorsettings/websocketprotocols-property/llms-full.txt)
- **Next:** [Javascript: DocumentLink.getAutoGenerationType Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlink/getautogenerationtype-method/llms-full.txt)
