# How To: Create Multi-Page Documents with Page Breaks

Use page break styling when document sections must start or stay together on specific pages.

### Problem

You need to control where page breaks occur in your generated documents.

### Solution 1: CSS Page Break

**Force a page break after a section:**

```
<div style="page-break-after: always;">
  <h1>Page 1 Content</h1>
  <p>This content appears on page 1.</p>
</div>

<div>
  <h1>Page 2 Content</h1>
  <p>This content appears on page 2.</p>
</div>
```

**Avoid a page break inside an element:**

```
<div style="page-break-inside: avoid;">
  <h2>Keep Together</h2>
  <p>This entire section stays on one page.</p>
  <ul>
    <li>Item 1</li>
    <li>Item 2</li>
  </ul>
</div>
```

### Solution 2: Table Row Page Breaks

**Keep table rows together:**

```
<style>
  tr {
    page-break-inside: avoid;
  }
</style>

<table>
<!--{{!
<lineitems>
<listname>opportunitylineitems</listname>
<column>PricebookEntry.Product2.name</column>
<column>Description</column>
</lineitems>
}}-->
</table>
```

### Solution 3: Conditional Page Breaks

**Break before certain categories:**

```
<!--{{!
<lineitemsSOQL>
<soql>SELECT Name, Category__c FROM Product2 WHERE Id IN (SELECT Product2Id FROM OpportunityLineItem WHERE OpportunityId = '{{!Opportunity.Id}}')</soql>
<column type="rtf" render="RECORD.Category__c == 'Services',lt#div style='page-break-before: always;'gt#lt#h2gt#Services Productslt#/h2gt#lt#/divgt#RECORD.Name,RECORD.Name"></column>
</lineitemsSOQL>
}}-->
```

### Tips

* `page-break-after: always` forces a break after the element.
* `page-break-before: always` forces a break before the element.
* `page-break-inside: avoid` keeps the element together.
* This works best in PDF output.
* Test with real content lengths before release.


---

# Agent Instructions: 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:

```
GET https://help.sdocs.com/sdocs/advanced-template-logic/template-attributes/template-attributes-how-to-guides/how-to-create-multi-page-documents-with-page-breaks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
