Confluence 5.6 has reached end of life
Check out the [latest version] of the documentation
This page provides information about 'advanced' PDF export customisations. These expand upon the regular customisations described in Customising Exports to PDF.
The information below is for advanced users. Customisations are not supported by Atlassian. Be aware that the advanced customisations described below require knowledge of certain parts of Confluence, and of CSS and HTML. This documentation is intended for advanced users. Some of the suggestions below are moderately complex, or irregular in nature. If you are having trouble understanding them we strongly suggest you ask an expert. We do not support any of the customisations described below. This means that the Atlassian support engineers will not be able to help you with these modifications.
By default, custom headers and footers set up in the PDF Layout screen (see Customising Exports to PDF), only apply to space exports and not to exports of single pages. However, it is possible to add CSS rules to your PDF Stylesheet that produce headers and footers in single page exports as well as space exports.
For custom headers, define @top-left, @top-center and @top-right rules within your @page rule. These rules apply respectively to content that appears on the left-hand side, centre and right-hand side of your page's header area.
For custom footers, define @bottom-left, @bottom-center and @bottom-right rules within your @page rule.
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:
@page
{
@top-center
{
content: "Document Title Goes Here";
font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
font-size: 8pt;
}
@bottom-center
{
content: "Page " counter(page);
font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
font-size: 8pt;
}
/* Any other page-specific rules */
}
Notes:
font-family and font-size properties 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.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.
<div style="margin-top:10mm"> <img src="/download/attachments/12346/header-image.png"/> </div>
In the example above, the header includes an image called 'header-image.png'. The "12346" in the src attribute is the ID number of the page to which the image is attached.
Follow these instructions to include an image on your page:
src="" attribute in your PDF Stylesheet, as shown above./download/....Notes:
margin-top in the style attribute 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.margin-bottom:XXmm property to force an image away from the bottom of the page by 'XX' mm.margin-top properties in the @page CSS rule.text-align:center or text-align:right properties to your style attribute. For example, to align the header image to the right-hand side of the page, your style attribute would look similar to this: style="margin-top:10mm; text-align:right".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:
@font-face
{
src: url(file:///usr/share/fonts/Consolas.ttf);
-fs-pdf-font-embed: embed;
}
.code pre, .preformatted pre, tt, kbd, code, samp
{
font-family: Consolas, monospace;
font-size: 9pt;
}
The font path specified in the CSS must be the path to the font on the Confluence server.
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.
.fsTitlePage
{
position:relative;
left:0px;
}
/* Turn off the default section numbering for this TOC item */
.toclvl0:before
{
content: " ";
counter-reset: chapter 0;
}
/* Hide the default page numbering for this TOC item */
.toclvl0 .tocnum
{
display: none;
}
/* Move and style this TOC item */
.toclvl0
{
position:absolute;
top:250px;
font-size: 42px;
font-weight: bold;
margin: 72px 0 4px 0;
text-align:center;
}
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:
Add the following CSS to your PDF stylesheet to make the PDF export recognise the NoPrint macro:
.noprint
{
display: none ;
}
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:
<confluence-home>/temp/htmlexport-20110308-154047-1/export-intermediate-154047-2.html