Confluence : Customise Adobe PDF Exports
This page last changed on Mar 15, 2007 by ganand.
Confluence pages can be output to PDF and some resulting PDF content can be modified. While page content itself is not open to customisation without major source-code modifications, this guide covers the easier task of modifying the plain text contained in page titles, headers and footers. How To Edit ContentConfluence uses Apache FOP to write Confluence content to XSL-FO format, and uses Velocity macro files to render PDF headers, footers and page titles. For information on more content editing, study the XSL-FO examples. Always stop Confluence before editing a Velocity macro file. Users who are stuck can obtain technical assistance by posting the modified Velocity file to the Confluence Developer Forum. List Of PDF-Related FilesUnder your Confluence install directory: .../confluence/WEB-INF/classes/com/atlassian/confluence/importexport/common_header_fop.vm .../confluence/WEB-INF/classes/com/atlassian/confluence/importexport/common_footer_fop.vm .../confluence/WEB-INF/classes/com/atlassian/confluence/importexport/common_fop.vm .../confluence/WEB-INF/classes/com/atlassian/confluence/pages/Page.pdfexport.vm
TextInserting the example XSL-FO tag below into the relevant Velocity macro file will output a new line with This text is printed in plain text. <fo:block text-align="left" font-family="$generalUtil.getDefaultFontFamily()" color="#0050B2"> This text is printed </fo:block> ImagesThere are two steps involved in adding images to the header and the footer:
<fo:block> <fo:external-graphic width="auto" height="auto" src="c:/images/operahouse.png" /> </fo:block> Modify Page Title for Single Page ExportThis title appears once on the first page of the PDF. An example title is Demonstration Space : Timesheets This page last changed on Nov 02, 2006 by Administrator To modify the page title, go to your Confluence install directory and modify the Velocity macro file ...\confluence\WEB-INF\classes\com\atlassian\confluence\pages\Page.pdfexport.vm The file contents are shown below <fo:block text-align="left" font-family="$generalUtil.getDefaultFontFamily()" font-weight="bold" color="#0050B2"> $generalUtil.escapeXml($page.space.name) : $rendererBean.nativeToAscii($generalUtil.escapeXml($page.title)) <fo:leader leader-pattern="rule" leader-length="100%"/> </fo:block> <fo:block color="grey" font-size="8pt" space-after.optimum="12pt"> This page last changed on $generalUtil.format($page.lastModificationDate) by <fo:inline color="#0050B2">$!page.lastModifierName</fo:inline>. </fo:block> Explanation of the Velocity code from the above example
Modify Page Headers for Space ExportBy default, no page header is printed with PDF exports. To add one, go to your Confluence install directory and modify the Velocity macro file ...\confluence\WEB-INF\classes\com\atlassian\confluence\importexport\common_header_fop.vm Example Header ModificationIn between the two FO lines, add <fo:block text-align="left" font-family="$generalUtil.getDefaultFontFamily()" color="#0050B2"> Custom Header </fo:block> Modify Page Footers for Space ExportPage footers appear on the bottom of every page. An example footer is Document generated by Confluence on Dec 11, 2006 09:35 Page1 To modify the footer, go to your Confluence install directory and modify the Velocity macro file ...\confluence\WEB-INF\classes\com\atlassian\confluence\importexport\common_footer_fop.vm Example Footer ModificationTo produce this footer Created on Dec 11, 2006 11:43 Copyright Altassian Software Locate this line in common_footer_fop.vm <fo:block>Document generated by Confluence on $generalUtil.formatDateTime($exportDate)</fo:block> Replace it with the following Velocity code <fo:block>Created on $generalUtil.formatDateTime($exportDate)</fo:block> <fo:block>Copyright Altassian Software</fo:block> Modify PDF Page Size for Space ExportThe default PDF page size is A4 (210mm x 297mm or 8.27in x 11.7in). Modify the file under your Confluence install directory: .../confluence/WEB-INF/classes/com/atlassian/confluence/importexport/common_fop.vm This file is pretty self-explanatory. Change to the following values:
Optionally you can modify the margins. To give the page a half-inch margin all around:
|
![]() |
Document generated by Confluence on Mar 22, 2007 21:00 |