How to create your own PDF Template
As you made it this far ...
Stay up to date with our monthly newsletter and get more articles, tips and tricks like these straight to your inbox.
All set! You'll receive our newsletter at the end of each month.
Please visit our subscription center to select the types of updates youd like to receive from us (tips and tricks, product and service updates etc).
Article updated on 20th December 2023 with information about the client-side PDF Export app (bundled by default in XWiki since 14.10). If you are using a newer version of XWiki, starting 14.10, and you're interested in creating a custom PDF Template with the client-side PDF Export app, check out the instructions on the documentation page .
The subject of this article remains the creation of a PDF Template while using the old PDF Export (present on versions before XWiki 14.10), with an example done on XWiki Jetty 13.4.5.
Have you considered to personalize the look of your PDF exported wiki pages? Let's say you'd like to export a purchase order that you created for your client who just bought your services. Or, you'd need to export a monthly report for the management team wanting to explore financial evolution measurements, which would help skyrocket your sales. Your original page contains a table, a diagram, a chart, and an infobox where you highlight services details. Apart from this, you'd like to make your exported PDF even more professional, so you'd like to add to it cover page, a table of content and a footer section with your company details. This is all possible with XWiki with a little bit of help from a more tech-savy colleague.
What do you need for your PDF export?
How to add the pdfclass page, do i need to add anything special in my wiki page, how to add the pdf template page, how to use the new pdf template, advanced documentation and examples, here is the exported pdf of my report.
You'll need 3 main ingredients: a PDFClass page, a wiki page to be exported as a PDF, and a PDF Template page.
I created an example of a page for this article, named My Report . You will see how to personalize the look of headings, message macros (info, box, warning, error, success, code), of a diagram, an image in a gallery macro, a chart and of tables in a PDF exported from your wiki.
Firstly, make sure you are an advanced user in the wiki, by going to your user profile, the preferences section and selecting the Advanced type of user. After that, you will be able to edit pages in object mode or to create terminal pages. Create a new terminal page which you would need to name "PDFClass", with "XWiki" as parent of the page. This will represent the object containing the customization properties that will then be added to your PDF template. After you create and save this new page, edit the page in "Class" mode (e.g. https://yourserver/xwiki/bin/edit/XWiki/PDFClass?editor=class ) and add the following TextArea properties:
- style : contains the CSS rules used to render the content as PDF.
- cover : if you want to modify the cover of your PDF export.
- header : if you'd like to add a specific text or image on the header of each page of your PDF export.
- footer : if you need a specific content on your page footer, such as contact details of your company.
- (optional) xhtmlxsl : contains the XHTML2FO XSL transformation into HTML, text, or other XML document types, which will override the default one. Note that you can also use velocity in this field (useful to get the content of an attached .xsl file, which comes in very handy when you need to fill in a big file, since the limit of textarea properties is of 60 000 characters).
- (optional) fopxsl : contains the FOP XSL transformation that will override the default one.
Note that the css that would be added in the style property will override the default pdf.css values. However, by default, there won't be a pdf.css file on your filesystem, but you can create it in the folder \webapps\xwiki\templates\ or add it in your skin page from the administration of your wiki, the Look and Feel section, the Themes tab.
Also the xhtmlxsl and the fopxsl properties are not mandatory, as these would be needed only if you would want to override existing values.
While editing the PDFClass page in class mode, make sure that you set the suitable Content and Editor types for the properties that you add. For my example, I used:
- for the style I used the PlainText option for both Editor and Content Type metadata.
- for the cover , header and footer I picked the option Wiki Syntax in the Content Type metadata, and PlainText for the Editor metadata
The answer is yes , but no need to panic. It would simply be a need to add some classes to elements of your page in order to easily target them in the style added in the PDF Template page.
For example, for a table, I added in source editor mode (% class="mytable" %) above the desired table. I added classes to the heading sections as well, because I want to add style on them as well. Then, on the macros, on some of them (like the info, warning, gallery macros) you can add a cssClass directly when adding them on the page or later on, when editing the macros or also in source editor mode.
On the images from the gallery below you can see the page that will be exported as a PDF edited in Source mode and the classes of the sections that will get targeted by the CSS added in the style object of the Report PDF Template.
Create a new terminal page (for example "Report PDF Template") with XWiki as its parent, save it and then edit it in "Object" mode (e.g. https://yourserver /xwiki /bin/edit/XWiki/reportPDFtemplate?editor=object ). Add the newly created PDFClass object to it. In the "style" property section you will be able to add the desired styling targeting your pages that you want to export as a PDF file. I then started to fill in the style property with CSS code. I placed in this snippet the complete CSS used for the PDF export from this article.
These code lines were then placed in the following cover, header and footer property:
- in the cover property, I added an image that was attached to the Report PDF Template page and I set a title
- in the header property, I added a smaller image that was attached to the Report PDF Template page and the same title as on the cover
- in the footer property, I added the page number, an email address for contact, a website and a line describing on which type of XWiki instance the example was done
There is already a possibility to export your XWiki pages as PDFs. Let's consider my example of a wiki page named My Report . I click on the Export option, select the PDF one, pick the sections that I want to export along with the page (e.g. cover, table of contents, header, footer), and then I click on the Export button. You would obtain a regular look, without no personalization. Here is how to get the styling added in the ReportPDFTemplate page:
- One would be to add in the URL of the exported file the name of the PDF template with the space name that locates the file. When exporting without the cover, table of contents, header and footer the URL would look like: https://yourserver/xwiki/bin/export/myreport/WebHome?pdftemplate= XWiki.reportPDFtemplate &format=pdf and with the table of contents, cover, header and footer selected for export the URL would look like: https://yourserver/xwiki/bin/export/myreport/WebHome?pdftemplate=XWiki.reportPDFtemplate&format=pdf&pdfcover=1&pdfcover=0&pdftoc=1&pdftoc=0&pdfheader=1&pdfheader=0&pdffooter=1&pdffooter=0
- A second option would be to use an extension that was build for the purpose to pick from multiple PDF templates when exporting a page . However, please note that the extension has not been maintained throughout the years.
Here is the documentation page describing how to customize the look and feel of your exported PDF (referring to the old PDF Export present on XWiki versions before 14.10) with an advanced look on each component and how they work. You'll notice there more advanced methods to customize your exported PDF: modifying the skin of your wiki or overriding the xhtml2fo.xsl file with specific rules to your desired to-be-exported page.
Check out the snippets containing two examples of styling:
- Add table borders to your PDF
- Add a complete look for your customized PDF template (the CSS style used for the PDF export of My Report from this article)
What would you like to add in your customized PDF export? Let us know in the comments below or on social media. We can gladly share with you how you could contribute with more styling scenarios or guide you to get the right services, depending on your needs.
Check out the PDF Viewer Macro which allows users to load and view PDF files inside a wiki page. The Viewer supports a double full screen mode: first going full screen in your browser and then going full screen on your computer if your browser supports that mode. The PDF location could be the current wiki page, another wiki page or an external URL.
Don't forget to share this post!
You may also be interested in:
Pro apps status for 2023 🔭, is xwiki free a comprehensive guide, webinar overview: introducing confluence migrator (pro) - multi space import and other improvements.
- Comments (2)
- XWiki Standard
- Business Apps & Connectors
- XWiki Procedures
- Standard Services
- Knowledge Base
- Procedures Management
- Extranet and Communities
- Digital Workplace
- Custom Apps
- Custom Services
- Our Methodology
- XWiki Store
- Compare XWiki Versions
- Compare XWiki with Other Products
- Help Center
- XWiki Network
- Libre & Open Source
- References & Partners
- Subscription center
Watermark in exported pdf file
I need to show watermark on each page of exported file. Pls tell how can I…
One of the simple and free solution to Add Watermark in PDF Software apply watermark to multiple PDF A few days back one of my friend was also facing the same issue and I suggested him to use this professional solution to insert watermark in PDF files. Must say this tool easily add image or text watermark on multiple PDF documents. VISIT https://www.osttopstapp.com/pdf-watermark.html
XWiki Platform PDF Export UI Korean
- Download translation
- Data exports
- Failing checks
- Share on Facebook
- Engage page
- Status widgets
Strings status, other components, string statistics, activity in last 12 months, quick numbers, trends of last 30 days, quick downloads.
- Untranslated strings • state:empty
- Unfinished strings • state:<translated
- Translated strings • state:>=translated
- Strings marked for edit • state:needs-editing
- Strings with suggestions • has:suggestion
- Strings with variants • has:variant
- Strings with screenshots • has:screenshot
- Strings with labels • has:label
- Strings with context • has:context
- Unfinished strings without suggestions • state:<translated AND NOT has:suggestion
- Strings with comments • has:comment
- Strings with any failing checks • has:check
- Approved strings • state:approved
- Strings waiting for review • state:translated
- Position and priority
- Source string
- Target string
- Last updated
- Number of words
- Number of comments
- Number of failing checks
- String location
- Source strings
- Target strings
- Key/Context strings
- Source string description
- Location strings
- String state
- Pending string
- String target language
- String changed by
- Strings with suggestions
- Strings with comments
- Strings with any failing checks
- Strings without screenshots
- Pluralized string
- Strings with context
- =">String changed after
- String changed before