# Javascript: HeaderFooter.setDistance Method

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

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

---

### Description

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

### Syntax

```javascript
<void> HeaderFooter.setDistance(<Number> distance, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

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

### Examples

The following example demonstrates `HeaderFooter.setDistance` in a practical document-editing workflow. It sets 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 configureDistance(headerFooter) {
    headerFooter.setDistance(
        1440,
        function() {
            console.log("set distance completed.");
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [Javascript: HeaderFooter.setConnectedToPrevious Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/headerfooter/setconnectedtoprevious-method/llms-full.txt)
- **Next:** [HeaderFooterCallback Function](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/headerfootercallback/llms-full.txt)
