# HeaderFooterCollection Object

> Contains all headers and footers in a document or part of the document.

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

---

### Description

Contains all [headers and footers](https://docs.textcontrol.com/ds-server/reference/javascript/headerfooter/llms-full.txt) in a document or part of the document.

### Syntax

```javascript
HeaderFooterCollection
```

### Examples

The following example demonstrates `HeaderFooterCollection` in a practical document-editing workflow. It contains all headers and footers in a document or part of the document.

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

TXTextControl.headersAndFooters.getItem(
    TXTextControl.HeaderFooterType.Header,
    function(headerFooter) {
        if (!headerFooter) {
            console.warn("No header footer was returned.");
            return;
        }
        
        console.log("get item result:", headerFooter);
    },
    onTxError
);
```

---

## In This Section

- [Javascript: HeaderFooterCollection.add Method](https://docs.textcontrol.com/ds-server/reference/javascript/headerfootercollection/add-method/llms-full.txt): Adds a new header or footer to a document or to a certain section of the document. If a header or footer is added to the complete document the first section receives the header or footer and all other sections receive headers or footers which are connected to their previous section. To add more than one header or footer a combination of the HeaderFooterType enumeration values can be used.
- [Javascript: HeaderFooterCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/headerfootercollection/getitem-method/llms-full.txt): Gets a particular header or footer from the collection.
- [Javascript: HeaderFooterCollection.remove Method](https://docs.textcontrol.com/ds-server/reference/javascript/headerfootercollection/remove-method/llms-full.txt): Removes a header or footer from the document or from a certain section.

---

## Nearby

- **Previous:** [HeaderFooterCallback Function](https://docs.textcontrol.com/ds-server/reference/javascript/headerfootercallback/llms-full.txt)
- **Next:** [Javascript: HeaderFooterCollection.add Method](https://docs.textcontrol.com/ds-server/reference/javascript/headerfootercollection/add-method/llms-full.txt)
