Keeping images with previous in PDF exports
Asked by Tom Crowley:

Hi,

When I export my space to PDF in Confluence Cloud, my images do not always fit on the same page as the content before them, and so are exported onto the following page as the first item.

I want the paragraph immediately before the image to always be on the same page as the image.

I've tried to set this up in the PDF Stylesheet, but to no avail.

I have tried the following (both with and without \`!important\`):

```
.confluence-embedded-file-wrapper {
  page-break-before: avoid !important;
}
```

and

```
.confluence-embedded-image {
page-break-before: avoid !important;
}
```

However, neither work.

Is this not supported? Or am I doing something wrong?

Any guidance is much appreciated.

Cheers,

Tom


Answers:
author: Diego
body: Hello there Tom!

Using only CSS styling I believe that this is not achievable. However, we can manually insert a *Page Break* by using the following *User Macro*:
> ## @noparams  
> \<div style="page-break-before:always;"\>\</div\>

To *create a user macro,*we can do the following:
> 1. Click the ***Cog Icon***at the top right cornet
> 2. Select ***General Configuration***
> 3. Search for ***User Macros***in the left side menu
> 4. Click to ***Create a User Macro***
> 5. Under ***Macro Name***type page-break
> 6. Under ***Visibility***select "Visible to all users in the Macro Browser"
> 7. Under ***Macro Title*** type Pagebreak
> 8. You can leave ***Description, Categories, Icon URL, Documentation URL*** all as is
> 9. Under ***Macro Body*** Processing select No macro body
> 10. Under the ***Template*** text box, paste the code in the excerpt above
> 11. ***Save***

After we create this macro, all we need to do is insert it ++*before the paragraph*++ that precedes the image and it should appear in the same page as the image.

Let us hear from you Tom. Looking forward to your reply!

comments: author: Tom Crowley
body: I was under the impression you couldn't create your own macros in Confluence Cloud. I can't see a cog icon in the top right-hand corner. The cog icon (Settings) in the left-hand sidebar does have a General Configuration option, but this has no option for User Macros.

If you could let me know exactly how to find this page, that would be helpful, although it sounds like a lot of effort to set the macro in the middle of an ordered list for several images...

Thanks


author: Diego
body: Hello there, thanks for keeping the thread moving.

You are correct, Tom. U*++ser macros are only available for Confluence server.++*

According to our documentation, this is not possible in Confluence Cloud:
> * ++***[How to create a page break function in Confluence to control pagination in PDF exports](https://confluence.atlassian.com/confkb/how-to-create-a-page-break-function-in-confluence-to-control-pagination-in-pdf-exports-735943076.html)***++

Here we can have a better look at the differences between Cloud and Server:
> * ++***[Functional differences in Confluence Cloud](https://confluence.atlassian.com/confcloud/functional-differences-in-confluence-cloud-734070955.html)***++

Looking through our reports, I could find this:
> * ++***[CONFCLOUD-36146 \| Provide ability for OnDemand users to insert page breaks to have a clean pdf export](https://jira.atlassian.com/browse/CONFCLOUD-36146)***++   

This report points directly to the feature needed in your case. You can *++vote and watch++* this report. Votes increase the report visibility and watching keeps you up to date.

Let us hear from you, Tom!


author: Tom Crowley
body: Created: 19-Jul-2012 3h49 PM

You'll forgive me for not believing that Confluence have any inclination to add this feature, and that as for watching it, I might as well watch paint dry.


author: Dee Elling
body: and.... the paint is still drying.


Tags: atl-adm

cloud

confluence-cloud