Server

HOWTO: Quickly Generate a PDF Using Document Template

This page is scheduled for review and update. Check back soon for updated content!

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
    

We'd love to hear your thoughts!

All fields required