# Javascript: HeaderFooter.getDistance Method

> Gets the distance, in twips, of a header or footer to the top or bottom of the page.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: HeaderFooter.getDistance Method
- **345 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/headerfooter/getdistance-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/headerfooter/getdistance-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/headerfooter/getdistance-method/llms-full.txt

---

### Description

Gets the distance, in twips, of a header or footer to the top or bottom of the page.

### Syntax

```javascript
<void> HeaderFooter.getDistance(<RequestNumberCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the distance, in twips, of a header or footer to the top or bottom of the page. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `HeaderFooter.getDistance` in a practical document-editing workflow. It gets the distance, in twips, of a header or footer to the top or bottom of the page.

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

function inspectDistance(headerFooter) {
    headerFooter.getDistance(
        function(result) {
            console.log("get distance result:", result);
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [Javascript: HeaderFooter.getConnectedToPrevious Method](https://docs.textcontrol.com/ds-server/reference/javascript/headerfooter/getconnectedtoprevious-method/llms-full.txt)
- **Next:** [Javascript: HeaderFooter.getType Method](https://docs.textcontrol.com/ds-server/reference/javascript/headerfooter/gettype-method/llms-full.txt)
