> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
