Create PDF documents from DOCX template
This article demonstrates how to generate PDF documents from a DOCX template with the help of Plumsail Documents processes. We will use a DOCX document as a template. And with the help of Processes, we will receive the result file in PDF format.
The Processes are a user-friendly intuitive interface for creating documents from templates, converting and delivering them to different systems for further management.
In this article, we will generate a PDF invoice, and this is how the final document will look:
Let’s go through the following steps and create a process for generating PDFs from a DOCX template.
Configure Process
First, log in or create your Plumsail account.
Create new process
For this example, we’ll use the prepared invoice DOCX template.
During process creation, click Add Process and select Upload a document. Then select the downloaded invoice template.
Enter a Process name and select PDF as the Output file type.
The Modern template engine is activated by default. Press Create to finish.
If you prefer to create your own template, click Add Process and select Start from blank instead.
Configure template
Once the process is created, proceed to configure the template.
There are several template configuration options:
Editor
Settings
The Editor allows you to edit an uploaded template using the Online editor, Upload, or Download options.
Templating syntax
When designing your own template from scratch, start by reviewing the templating language used in Plumsail Documents. Plumsail Word DOCX templates use a different approach compared to other templating solutions, utilizing minimal syntax to get the job done.
To learn more about the templating engine, check out how the DOCX templating engine works.
Essentially, the templating engine interprets everything between the curly {{ }} brackets as a variable, dynamically applying your specified data. In our case, the most simple tokens would be {{@number}} and {{@date|format(dd.MM.yyyy)}}. They let the engine know that we want to render the invoice number and its date.
However, we can also implement more complex scenarios. In our template, we reference properties within a collection of products using nested tokens with a dot operator:
The
{{products.name}},{{products.price}}tokens retrieve the name and price properties of the product.
The templating engine is smart enough to identify which content needs to be duplicated. It iterates through all objects in the array, rendering each one and automatically adding the necessary rows.
You can learn more about table rendering in the tables section of the documentation.
Test template
To visualize the document before saving it, click Test template. A dialog window will pop up where you can fill in the auto-generated testing form.
Form fields are created based on the tokens from your document template. You can adjust the look of the testing form by changing token types.
Template settings
After preparing your document template, configure the output filename and file type.
Go to the template settings and configure the following settings:
Enter an Output filename for the generated file. Use tokens to include the invoice number in the filename. For example, using Invoice {{@number}} will result in a filename like Invoice 3.
Select PDF as the Output file type.
You can protect your final PDF document and add a watermark if you wish.
For more advanced customization, please review our template settings documentation.
Hint
You can also add multiple templates to the same process.
Once all settings are configured, click Save.
Switch the process to Production mode to remove Plumsail watermarks from resulting documents.
Add Delivery
The next step is Delivery. In our example, we’ll store the generated PDF files in OneDrive, but there are many other built-in delivery options available, such as Dropbox, DocuSign, SharePoint, email, and more.
First, you will be prompted to connect your OneDrive account to Plumsail. Then, create a folder where the generated PDF documents will be saved. Tokens can be used here as well.
You can add as many deliveries as needed.
Start Process
Everything is now ready for you to begin generating PDF documents from a DOCX template. In the Start process step you have several options to trigger document generation, which are listed below.
You can start the process:
submitting JSON corresponding to template tokens;
Use Power Automate Flow, Zapier and Make to integrate the Documents Process with other apps. This allows you to collect data from one application and pass it into the process to populate a DOCX template and generate a PDF document. You can use data from various web forms, CRM systems, SharePoint lists, and thousands of other web applications to complete your DOCX template.
Hint
You can create a fillable PDF and use it as a template for generating PDF documents with Plumsail Processes. This file format is also supported.