Confluence – hiding content from PDF export

Confluence has the ability to produce reasonable PDF exports of pages, which can be further customized using CSS to add corporate logos, footers etc.

As a wiki much of the power comes from dynamic features such as links to related items, or making notes at the end of pages, but this is not always appropriate or useful in a static export.

The following macro adds a section to a page which will not be exported.

Creating the Macro

Create a new User Macro (Administration – Configuration – User Macros) with the following details

|Macro Name|hidden-pdf-panel| |Visibility|Visible to all users in the Macro Browser| |Macro Title|Hidden PDF Panel| |Description|A panel which will be hidden when exported to PDF| |Categories|Formatting| |Documentation URL|This page URL| |Macro Body Processing|Rendered|

Template code below

## Macro title: Hidden PDF Panel
## Macro has a body: Y
## Body processing: Rendered

## @noparams

<div class="pdfhidden" style="position: relative; margin: 0px -8px; border: 2px dashed #CCCCCC; padding: 4px"><div style="font-size: 10px; font-weight: bold; color: #CCCCCC; position: absolute; top: 0px; right: 2px">hidden</div>$body</div>

Setting the CSS for the PDF Export

Edit the Global PDF Styles (Administration – Look and Feel – PDF Stylesheet) to add the following CSS snippet at the end:

/* Hidden panels */
div.pdfhidden {
  display: none;
}

That’s it – you can now use the macro on pages to have non-PDF-exported content, like this:

Leave a Reply

Your email address will not be published. Required fields are marked *