In Q2 2023 we released an update to PDF export that renders Confluence pages more accurately. However, this update does not support the customizations described in this page and will fall back to the older method of PDF export that does not render Confluence pages as accurately if these customizations are detected.
Confluence and space admins can customize the PDF exports for individual spaces.
Considerations
For further customizations, see the Advanced PDF Export Customizations page.
You can add your own HTML to customize the title page, page headers, and page footers in the PDF export output.
You can adjust the appearance of the PDF pages by customizing the CSS in the PDF stylesheet field.
To get started, download the default CSS rules for the PDF stylesheet: confluencedefaultpdf.css. Any rule defined in this file can be customized and added to the PDF Export Stylesheet field. Your customizations override any default CSS rule. If no customizations are defined, the default CSS rules are applied.
By default, the export doesn't include a title page, headers, or footers. You can define these in the PDF layout.
This section provides examples of typical customizations you can add. You can also check out Advanced PDF Customizations.
The default page size is based on the location of your Confluence instance. For example, if this instance is located in the US then the default paper size of your PDF export will be US Letter (8.5 inches wide by 11 inches long). If the instance is located in Australia, the default paper size will be A4 (210 mm wide by 297 mm long). More information about paper sizes can be found on Wikipedia.
To modify the page size to A4, edit the PDF Stylesheet to add a size property to the CSS@page rule, like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 CSS - PDF Stylesheet @page < /*The A4 paper size is 210 mm wide by 297 mm long*/ size: 210mm 297mm; >To change the page orientation of your PDF document, simply reverse the order of the values declared in the @page rule's size property. The first and second values of this property represent the width and height of the page, respectively.
For example, to generate PDF space exports in A4-sized landscape orientation, your @page rule might look like this:
1 2 3 4 5 6 7 8 9 10 11 CSS - PDF Stylesheet @page < /*A4-sized pages in landscape orientation are 297 mm wide by 210 mm long*/ size: 297mm 210mm; >To set all margins to 15 mm, with a paper size of A4, edit the CSS @page rule in the PDF Stylesheet, like this:
1 2 3 4 5 6 7 8 9 10 11 12 CSS - PDF Stylesheet @page < size: 210mm 297mm; margin: 15mm; >To set the margins independently, edit the @page rule as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 CSS - PDF Stylesheet @page < margin-top: 2.54cm; margin-bottom: 2.54cm; margin-left: 1.27cm; margin-right: 1.27cm; >To set margins to provide a gutter for binding a printed document, use the :left and :right pseudo-classes, as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 CSS - PDF Stylesheet @page :left < margin-left: 4cm; margin-right: 3cm; >@page :right < margin-left: 3cm; margin-right: 4cm; >@page :first < margin-top: 10cm /* Top margin on first page 10cm */ >
Note the use of the :first pseudo-class in the example above to define distinct margins for a cover or title page.
By default, Confluence pages are exported without page breaks, so that shorter pages will appear on the same PDF page.
To make each Confluence page appear on a separate page in the PDF file, add the following rule in the PDF Stylesheet:
1 2 3 4 5 6 7 8 9 10 11 CSS - PDF Stylesheet .pagetitle < page-break-before: always; >You can add a title page to your PDF document by adding HTML to the Title field of the PDF Layout. The following example creates the title page and adds a title:
1 2 3 4 5 6 7 8 9 10 HTML - PDF Layout: Title Page Section
Use CSS rules in the PDF stylesheet field to control the appearance of the title page and the title text:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 CSS - PDF Stylesheet .fsTitlePage < margin-left: auto; margin-top: 50mm; margin-right: auto; page-break-after:always >.fsTitle < font-size: 42px; font-weight: bold; margin: 72px 0 4px 0; text-align:center; >In the example above, the title page includes an image called "titlepage.png," centered in the middle of the page. The "590719" in the src attribute is the ID of the page to which the image is attached.
Follow these instructions to include an image on your title page:
By default, a table of contents will be generated after the title page, or at the beginning of the PDF document if no title page is defined in the PDF Layout. To see the default CSS rules applied to the table of contents, download the default CSS rules (confluencedefaultpdf.css) and examine the specific rules with toc in their name.
To make changes to the appearance of the table of contents, define CSS rules in the PDF Stylesheet.
To prevent the table of contents from being generated in your PDF document, add the div.toc-macro rule to the PDF Stylesheet and set its display property to none:
1 2 3 4 5 6 7 8 9 10 11 CSS - PDF Stylesheet div.toc-macro < display: none; >The leader character is used to link a heading in the table of contents with its page number. By default, the leader character is the '.' (dot) character. Leader values of dotted , solid and space are allowed. You can also use a string, for example leader(". . . ") .
To change the leader character to a solid line, modify the leader() value on the content property of the CSS rule as follows:
1 2 3 4 5 6 7 8 9 10 CSS - PDF Stylesheet span.toclead:before < content: leader(solid); >You can add headers and footers to your PDF pages using the Header and Footer fields in PDF export . By default, headers and footers only apply to a space export and not to exports of single pages (however, see Advanced PDF Export Customizations). The following example adds a simple copyright notice.
1 2 3 4 5 6 7 HTML - PDF Layout: Footer Section Copyright © 2013, Atlassian Pty Ltd.To add page numbering, you need to combine customized HTML with customized CSS in the PDF stylesheet field.
Analyzing the above CSS selector rule in more detail:
In order to break long words or words that are not separated by whitespace, add a selector to the PDF stylesheet containing the word-wrap property with a value of break-word :
1 2 3 4 5 6 7 8 9 10 CSS - PDF Stylesheet div < word-wrap: break-word; >You can use the stylesheet to customize the output of just about anything else that will influence the look and feel of the final document. This includes fonts, tables, line spacing, macros, etc. The export engine works directly from the HTML output produced by Confluence. Therefore, the first step in customizing something is to find a selector for the HTML element produced by Confluence or the Confluence macro. Then add a CSS rule to the PDF stylesheet. Your customization will appear in the PDF export.