Nuxeo Server

How to Quickly Generate a PDF Using Document Template

Updated: September 22, 2017 Page Information Edit on GitHub

Use case: you want to get a PDF printable version of the data stored on your document as properties.

You may want to use Nuxeo Platform Template Rendering addon for this use case. That module will allow a much better control on the look&feel of your generated PDF, using MS Word or Open Office templating.

Method: You will use a FreeMarker template to generate an HTML document, then use the PDF converter operation to generate the PDF, and then the Download operation for letting the user getting it.

  1. In Studio, create the FreeMarker template (Templates > Document template). You can use the following sample for instance.

    <#list This as doc>
    
    <h1>${doc.title}</h1>
    
    <ul>
    
    <li>${doc.dublincore.description}</li>
    
    <li>${doc.dublincore.nature}</li>
    </ul>
    </#list>
    
  2. Create a user action on the document (in the category you want).

  3. Create the related automation chain (see How to Create an Automation Chain) with the following operations:

    - Context.FetchDocument
    - Render.Document:
        template: "template:MyDocumentTemplate"
        filename: output.ftl
        mimetype: text/html
        type: ftl
    - Blob.ToPDF
    - Seam.DownloadFile
    

3 days ago manonlumeau NXDOC-1323: Update BDE doc
2 years ago Solen Guitter 18
3 years ago Solen Guitter 17
3 years ago Solen Guitter 16
3 years ago Solen Guitter 15
3 years ago Solen Guitter 14
3 years ago Solen Guitter 13
3 years ago Solen Guitter 12 | Add FreeMarker Document template sample
3 years ago Solen Guitter 11
3 years ago Solen Guitter 10 | Formatting and link update
3 years ago Manon Lumeau 9
3 years ago Manon Lumeau 8
3 years ago Alain Escaffre 7
4 years ago Solen Guitter 6
5 years ago Alain Escaffre 5
5 years ago Alain Escaffre 3
5 years ago Alain Escaffre 4
7 years ago Alain Escaffre 1
7 years ago Alain Escaffre 2 | Migrated to Confluence 4.0
History: Created by Alain Escaffre