Setting a page break for PDF export

Hi, I am a newbie with page styles and pdf exports and so I'd appreciate some help with exporting pages to PDF and correctly using page breaks.

I would like to use an image or (ideally) a hidden element of the page content to force a page break when exporting to PDF. I have seen style sheet code which breaks on h1, h2 etc.... but I don't know what h1, h2 etc are.

Ideally I would like to be able to insert a user macro at the point I want the page to break when exported. When viewing it would remain invisible.

Please be gentle in pointing out the scale of my ignorance.

Regards, Jon

6 answers

1 accepted

This widget could not be displayed.

Hi Jonathan.

H1 etc is HTML tags (paired) It is tag for Headings. H1 is top level heading, h2 second one ....

H1 tags, p tags etc is blocked, so everytime is there break new line after them.

If you need break, use <br> tag.

HTML is covered by W3 Consorcium. They have many examples and tutorials and really awesome web http://www.w3schools.com/html/html_basic.asp

If you need a new page, you have to use styles for it. It is called CSS (Cascade Style Sheet), more info on w3 web :)

If you have some element (HTML tag) on page, for example H1, and you want to have it on a new page , you can create class in CSS, define there that page breaking, and then use H1 with class definition of breaking. Examples :)

&lt;style&gt;
.break { page-break-before: always; }
&lt;/style&gt;
&lt;body&gt;
content on page 1...
&lt;h1 class="break"&gt;text of Heading 1 on page 2&lt;/h1&gt;
content on page 2...
&lt;h1 class="break"&gt;text of Heading 1 on page 3&lt;/h1&gt;
content on page 3...
&lt;p class="break"&gt;content on top of page 4&lt;/p&gt;
content on page 4...
&lt;/body&gt;

And here it could be for ALL H tags :)

&lt;style&gt;
h1{ page-break-before: always; }
&lt;/style&gt;
&lt;body&gt;
content on page 1...
&lt;h1&gt;text of Heading 1 on page 2&lt;/h1&gt;
content on page 2...
&lt;h1&gt;text of Heading 1 on page 3&lt;/h1&gt;
content on page 3...
&lt;/body&gt;

Thanks for this, I can see some study is in order. You've helped me a great deal.

I hope that It will help you :) If you need any advice in CSS, write comment here :)

Have a nice day!

This widget could not be displayed.

Insert, anywhere you want the page break to happen, a "Div" macro with the "Style":

page-break-after:always;

FYI, this still works (May 2017). I particularly like it because unlike other "solutions" here, it doesn't require you to have access to create user macros or edit stylesheets. 

Yep, still works. I wish there was a way to achieve the same result globally for all pages, without using any macros. Seems like it should be a simple enough option.

I second Nir! How is this not native to Confluence?

This widget could not be displayed.

That last answer works well and is the simplest. In steps it is:

  1. Edit the confluence page then place the cursor at the line where you need a page break
  2. Select the plus sign to insert more content then select Other Macros
  3. In the left hand filter column, select formatting then div
  4. In the Style field paste in the following: page-break-after:always;

I am relatively new to using Confluence, so please pardon my ineptitude. When I click "Formatting", I don't see "div" as an option. Listed alphabetically, it goes from "CSV" to "Expand". Is there something I need to do first to be able to see it? Have they removed this as an option since this post?

Thank you for this!  I've been looking for this solution for a while.  :)

This widget could not be displayed.

Hi Jonathan.

Content Exporter for Confluence addon has a built-in page break macro. That should be an easy fix for your question:

https://marketplace.atlassian.com/plugins/com.metainf.confluence.plugin.pagetreeexporter.pagetree-word-exporter-plugin/cloud/overview

This widget could not be displayed.

Hi Jonathan,

if you are using our Scroll PDF Exporter, you can create a user-macro to insert page-breaks. The usermacro is not visible in the Confluence view, but will be inserted when exporting to PDF.

Please have a look at the following page for further details how to create this macro: Adding Pagebreaks.

Besides you can simply define page breaks using CSS, e.g. to always break before a heading 1 (h1), see Enforcing Pagebreaks.

Hope that helps.

If you have any further questions regarding Scroll PDF Exporter, please feel free to contact support@k15t.com. I'll be happy to help.

Cheers,
Nils

This widget could not be displayed.

Benoit thank you for taking the time to post this.  This worked for me.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

603 views 8 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you