This is the documentation for an older version of Scroll PDF Exporter. Here you can view the most up-to-date version of the Scroll PDF Exporter documentation.

Avoiding page breaks in certain positions

Sometimes, unwanted page breaks can cause formatting problems in PDF exports. To solve this, you can create a custom user macro which ensures that certain elements remain together, and are not separated across different pages.

Creating the macro

Firstly, you need to create the macro.

On the Create User Macro screen, Fill in Macro Name as 'keep-with-next' and Macro Title as 'Keep with Next'.

Choose Macro Body Processing as 'Rendered', and fill in the Template text box with the following code:

## Macro title: My Macro 
## Macro has a body: Y 
## Body processing: Selected body processing option

## Output: Selected output option

## Developed by: Robert Lauriston

## Date created: dd/mm/yyyy

## Installed by: Robert Lauriston

## @noparams
## For use with Scroll PDF Exporter

<p class="keep-with-next">$body</p>

Now, you have created the user macro – but to make it work, you need to make your PDF exporter template recognize it.

Editing the PDF exporter template

Now, you need to edit the PDF template so that it can interpret the user macro.

Firstly, go to Space Tools > PDF Exporter, and click Edit for the template you want to use.

On the Content Formatting tab, insert the following snippet of code into the bottom of the template's Content section:

p.keep-with-next { 
page-break-after: avoid;

The macro is now ready to use.

Using the macro

Please note that captions created with the Scroll Title macro are not exported if you use them within this user macro.

Now, open up the Confluence editor and insert the 'Keep with Next' macro into the page.

All content you put inside the macro will now be on the same page as the following page element in all your PDF exports. In this example, the text and picture marked by the two red arrows will not be separated by page breaks, and will always be on the same page.

In the export, you can now see that the picture and the text are on the same page.


If the macro doesn't work, it is probably because the text in the macro contains hidden HTML tags that interfere with the way the macro functions. To get rid of these, highlight the macro in the Confluence editor and click 'clear formatting':