Skip to content

Usage ‐ PDF templates

Bart Don edited this page Jan 2, 2024 · 7 revisions

When opening the TTA module you will see the following: image Here you can see all templates and you can create new ones.

Creating a template

On the top right you can click on the add button.

Here you can fill in a form to create a new template.

After this you can click on a template and it will open up the editor: image The toolbar has the following actions (from left to right):

  • Edit template properties, edit the format/name ect here
  • Save, save the template
  • Resizer, resizes the editor + preview window
  • Close, close the template editor

The editor on the left allows you to use HTML to style your PDF.

It also allows you to use LiquidJS for any conditions/loops ect.

Using the template

Flows

You can use the template in Flows with the TTA operation:

The fields are self describing and allow for the flow tags {{}} to be used for any variables.

Programmatically

You can also generate PDF`s based on templates within Directus Hooks/Endpoints/Operations. This can be done trough globalThis.TTA.

An example usage:

const fileID = await globalThis.TTA.generatePDFFromTemplate({
  template: templateIDHere,
  templatevariables: { variableOne: "A", variableTwo: "B"}
});
Clone this wiki locally