> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-+-++/modules/bx-plus-pdf/components/documentitem.md).

# DocumentItem

Component which specifies header, footer, and pagebreaks within a document body

This component is available in the free-tier functionality of this module

## Component Signature

```
<bx:DocumentItem type=[string]
evalAtPrint=[string] />
```

### Attributes

| Atrribute     | Type     | Required | Description                                                                                                                                                                                                 | Default |
| ------------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `type`        | `string` | `false`  | string pagebreak                                                                                                                                                                                            | header  |
| `evalAtPrint` | `string` | `false`  | A boolean which determines if the contents of the cfdocumentitem tag body has to be evaluated at the time of printing the document. This attribute is deprecated as all content is evaluated at print time. | `true`  |

## Examples

### Document Header

```html
<bx:document format="pdf" filename="header-example.pdf">
    <!-- Global Header -->
    <bx:documentitem type="header">
        <div style="text-align: center; border-bottom: 2px solid #333; padding: 10px;">
            <h2>Company Annual Report</h2>
            <p>Confidential - Internal Use Only</p>
        </div>
    </bx:documentitem>

    <h1>Document Content</h1>
    <p>This content will appear on every page with the header above.</p>
</bx:document>
```

### Document Footer

```html
<bx:document format="pdf" filename="footer-example.pdf">
    <bx:documentitem type="footer">
        <div style="text-align: center; font-size: 10px; padding: 10px; border-top: 1px solid #ccc;">
            <p>Page #bxdocument.currentpagenumber# of #bxdocument.totalpages#</p>
            <p>© 2024 Your Company Name. All rights reserved.</p>
        </div>
    </bx:documentitem>

    <h1>Document Content</h1>
    <p>This content will appear on every page with the footer below.</p>
</bx:document>
```

### Page Break

```html
<bx:document format="pdf" filename="pagebreak-example.pdf">
    <h1>Section 1</h1>
    <p>Content for the first page...</p>

    <!-- Force a page break -->
    <bx:documentitem type="pagebreak" />

    <h1>Section 2</h1>
    <p>This content will start on a new page...</p>
</bx:document>
```

### Combined Header, Footer, and Page Breaks

```html
<bx:document format="pdf" filename="complete-example.pdf">
    <!-- Global Header -->
    <bx:documentitem type="header">
        <div style="text-align: center; background: #f0f0f0; padding: 5px;">
            <strong>Document Title</strong>
        </div>
    </bx:documentitem>

    <!-- Global Footer -->
    <bx:documentitem type="footer">
        <div style="text-align: center; font-size: 8px;">
            Page #bxdocument.currentpagenumber# | Generated on #dateFormat(now(), "mm/dd/yyyy")#
        </div>
    </bx:documentitem>

    <h1>Chapter 1</h1>
    <p>First chapter content...</p>

    <bx:documentitem type="pagebreak" />

    <h1>Chapter 2</h1>
    <p>Second chapter content...</p>
</bx:document>
```

## Built-in Variables

When using DocumentItem components, BoxLang provides special variables:

* `#bxdocument.currentpagenumber#` - Current page number
* `#bxdocument.totalpages#` - Total number of pages in the document

## Related Components

* [Document](/boxlang-+-++/modules/bx-plus-pdf/components/document.md) - Main component for PDF generation
* [DocumentSection](/boxlang-+-++/modules/bx-plus-pdf/components/documentsection.md) - Divides documents into sections


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-+-++/modules/bx-plus-pdf/components/documentitem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
