Advanced PDF Export Customizations
This page provides information about 'advanced' PDF export customizations. These expand upon the regular customizations described in Customize Exports to PDF.
The information below is for advanced users. Be aware that the advanced customizations described below require knowledge of certain parts of Confluence, and of CSS and HTML. Customizations are not supported by Atlassian, so our support engineers won't be able to help you with these modifications.
Header and Footer
Adding Headers and Footers to Single Page Exports
Single page exports don't support adding HTML headers and footers via the PDF Layout page, but you can use CSS rules in the PDF Stylesheet page (Space tools > Look and Feel > PDF Stylesheet) to produce headers and/or footers for a single page export.
For custom headers, define any of the following rules within your
@top-right. These rules allow you to define the
content of the left-hand side, centre and right-hand side of your page's header area, respectively.
For custom footers, define
@bottom-right rules within your
For example, the following rules add a document title at the centre of the header and a page number at the centre of the footer:Notes:
font-sizeproperties ensure that the header and footer text is rendered in the same default font style used for the body text, based on the default CSS rules.
- It is not possible to use this method to insert images (stored as attachments within your Confluence instance) into the headers and footers of single page exports.
Adding Images to Headers and Footers
To insert an image into the header or footer, add HTML to the Header or Footer section of the PDF Layout screen.
The following example uses an HTML
img element with
src attribute to add an image to the left of the header. The
src attribute refers to an image attached to a Confluence page. The image element is usually placed within a
div element container.
srcattribute is the ID number of the page to which the image is attached.
Follow these instructions to include an image on your page:
- Attach the image to a Confluence page.
- View the list of attachments on that page, then right-click the image and copy its location.
- Paste the link into the appropriate
src=""attribute in your PDF Stylesheet, as shown above.
- Edit the image URL so that it is relative, by removing the first part of the URL before
- This example uses an inline CSS property
styleattribute to force the image away from the top of the page by 10mm. This comes in handy when your header image is large enough to touch or spill over the top of the page.
- Likewise, for footers, you can use the
margin-bottom:XXmmproperty to force an image away from the bottom of the page by 'XX' mm.
- Very large images can spill over into the body of a page or alter the position of text or other elements used within a header or footer. In such situations, it is recommended that you reduce the size of the image and then attach it to your Confluence page again. If you prefer to keep the image size and want to move the content lower instead, you can do so by configuring the
margin-topproperties in the
- By default, a header or footer image is aligned to the left-hand side of the page. However, you can align this image to the centre or right-hand side of a page by adding either the
text-align:rightproperties to your
styleattribute. For example, to align the header image to the right-hand side of the page, your
styleattribute would look similar to this:
Incorporating Other Fonts
By default, Confluence provides Times New Roman, Helvetica or Courier fonts for use in PDF exports. You can use your own fonts for PDF exports by declaring them in a
@font-face CSS rule in your PDF Stylesheet.
The following CSS rule example shows how to declare the Consolas font and apply it to some elements for your PDF export:
The font path specified in the CSS must be the path to the font on the Confluence server.
Adding a Dynamic Title to the Title Page
When you export an arbitrary set of pages from Confluence, you may like to have a corresponding title added to the cover (or title) page automatically. This can be done (in a somewhat irregular way) by using the top level item from the default table of contents as the title. This method relies on having the exported pages structured as sub-pages of the top-level page. In other words, the pages to be exported should consist of a page (at the top-level) and all of its child pages. The result is that the title that appears on the cover page changes depending on the top-level page that is used for the export.
The CSS below moves, and styles, the top-level TOC item for use as the title on the cover page, and turns off the leader and page number normally associated with this item in the TOC.
Hiding Text from the PDF Output
This section describes a way to hide text from your PDF export. In other words, you can have text on the Confluence page that will not appear in the PDF export.
There are three steps:
Follow the instructions to define the NoPrint user macro.
- Use the NoPrint macro to mark some text on a Confluence page.
- Add the following CSS to your PDF stylesheet to make the PDF export recognize the NoPrint macro:
To obtain an index at the end of the exported PDF file, consider using the Scroll Wiki PDF Exporter plugin that is produced by K15t Software GmbH.
If styling is not working as expected, it is useful to look at the intermediary HTML source to which the CSS is applied. This intermediary HTML is created whenever you create an HTML export that contains multiple pages, and is stored in the
temp directory in Confluence's home directory. For example:
Was this helpful?
Thanks for your feedback!