As you build a layout, you may want some content to flow continuously, a block to stay together, or a new part to start on its own sheet. Tembuilder lets you combine these approaches within the same template.
Set the pagination behavior for each section in Config → Page breaks. This guide covers those options, long tables, and CSS rules that can affect page breaks.
1. Open a section’s page-break settings
Select the section in Structure, then open Config → Page breaks. There are two controls:
- Keep together: whether the section can split across PDF sheets.
- Page break: whether to force a break before or after the section.
The controls are independent. A section can start on a new sheet and still continue across several sheets when its content is long.
For a table or list with a variable number of rows, start with Keep together: Off and Page break: None to let the content flow.
2. Keep a content block together
Use Keep together: On for a short section that should stay intact, such as a signature, payment details, or a summary. If the remaining space is too small, the section moves to the next sheet.
3. Choose where a new section starts
Use Page break to separate document parts, such as starting the terms on a new sheet after an invoice.
| Option | Behavior |
|---|---|
| None | Do not force a break before or after the section. |
| Before | Start this section on a new sheet when content precedes it. |
| After | Start the next section on a new sheet. |
| Both | Break before and after the section when content exists on both sides. |
Both does not limit the section to one sheet. Keep together still controls splitting within the section.
A break at an existing page boundary does not add a blank sheet. For example, Before on the first section does not insert a blank sheet before the document.
4. Let long tables continue across sheets
Set Keep together: Off on the section containing the table. Use <thead> for the header and <tbody> for data rows. The <thead> header repeats when the table continues onto another sheet.
For service rows, generate table content from params.lineItems:
<table>
<thead>
<tr><th>Service</th><th>Quantity</th><th>Amount</th></tr>
</thead>
<tbody>
{{#each params.lineItems}}
<tr>
<td>{{ description }}</td>
<td>{{ qty }}</td>
<td>{{ amount }}</td>
</tr>
{{/each}}
</tbody>
</table>
To place totals after the final table row, put them after the table or in the following section with Page break: None. To keep the totals intact, enable Keep together on the totals section only.
See Arrays and objects for more on passing lists into a template.
5. When content is clipped or moves as a block
These symptoms usually point to different settings:
| Symptom | Where to look |
|---|---|
| A whole section moves to the next sheet, leaving a large gap | The section’s Keep together setting and break-inside on its container. |
| Final rows disappear at a container’s edge | The container’s CSS height, max-height, and overflow. |
| A section always starts on a new sheet despite available space | Its Page break: Before/Both, After on the preceding section, or CSS break-before. |
For example, an .items container with a fixed height and overflow: hidden clips anything beyond its box. If it should grow with the list, remove the height limit and allow visible content, as illustrated below.
.items {
height: 120px;
overflow: hidden;
}.items {
height: auto;
overflow: visible;
}Test pagination with changing JSON data
- Verify the first and final data rows are present.
- Check that the table header repeats on continuation sheets.
- Keep the totals or signature in a separate short section if it should stay together. Do not enable Keep together on the entire long table.
- Compare the PDF with the input data after saving changes and regenerating the preview.
Use the invoice template and sample JSON to try this workflow, and adjust page margins when the content area is too narrow.