|
All Versions
Confluence 2.0 to 2.5 Documentation
|
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 and page size. Change PDF page sizeThe 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 To change the page size for PDF export, page-width and page-height parameters have to be edited in the above mentioned file. Locate the line <fo:simple-page-master margin-right="2cm" margin-left="2cm" margin-bottom="1cm" margin-top="1cm" page-width="21cm" page-height="29.7cm" master-name="all-pages"> and change the values for page-width and page-height as required. 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:
Landscape orientationBy default the page orientation for PDF export is set to "Portrait" with page-width="21cm" and page-height="29.7cm". To change the orientation to Landscape, swap the page-width and page-height measurement values as shown below: <fo:simple-page-master margin-right="2cm" margin-left="2cm" margin-bottom="1cm" margin-top="1cm" page-width="29.7cm" page-height="21cm" master-name="all-pages"> This will generate a PDF export with a Landscape orientation. Editing PDF 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 Files.../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 TitleThis 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>
Example Header Modification with BannerBelow is a sample common_header_fop.vm velocity template for header with Banner. You need to update the value of <fo:region-before extent="1cm"/> on common_fop.vm template into 4 or 5 cm according to the size of your banner. <fo:static-content flow-name="xsl-region-before"> <fo:table width="100%" table-layout="fixed" font-family="serif" font-size="10pt"> <fo:table-column column-width="14cm"/> <fo:table-column column-width="3cm"/> <fo:table-body> <fo:table-row> <fo:table-cell color="grey"> <fo:block text-align="left" font-family="$generalUtil.getDefaultFontFamily()" color="#0050B2"> <fo:external-graphic width="auto" height="auto" src="/home/malam/Desktop/Temp/Top_Banner.jpg" /> </fo:block> </fo:table-cell> <fo:table-cell color="grey"> <fo:block text-align="right"> This is your Customer Header </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:static-content> A Sample of Custom PDF Header with A Banner on the top
A Sample of Custom PDF Header with A Logo on the Right Top
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> To produce a footer with a ruler on top and page number on right and some copy right content on bottom then you can use the sample common_footer_fop.vm template below <fo:static-content flow-name="xsl-region-after">
<fo:block>
<fo:leader leader-pattern="rule" leader-length="100%"/>
</fo:block>
<fo:table width="100%" table-layout="fixed" font-family="serif" font-size="10pt">
<fo:table-column column-width="14cm"/>
<fo:table-column column-width="3cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell color="grey">
<fo:block>Document generated by Confluence on $dateFormatter.formatDateTime($exportDate)</fo:block>
<fo:block>Created on $generalUtil.formatDateTime($exportDate)</fo:block>
<fo:block>Copyright Altassian Software</fo:block>
</fo:table-cell>
<fo:table-cell color="grey">
<fo:block text-align="end">Page <fo:page-number/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
Sample PDF Footer Image:
|
Customise Adobe PDF Exports
|
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 and page size. Change PDF page sizeLandscape orientationEditing PDF contentModify Page TitleModify Page Headers for Space ExportModify Page Footers for Space Export |


