Skip to main content

PDF templates

PDF templates are reusable designs (name and content in HTML/rich text) that allow generating PDF documents with variables. The content can include ERB-style placeholders that are filled in when the PDF is generated.

What it is used for

Define the layout and text of PDF documents that can be generated by name from code (from rules or, in local execution, from scripts), passing variables (locals).

Configuration

FieldDescription
NameUnique template identifier (used to invoke it by name)
ContentTemplate body in rich text (HTML)

Usage

From rules

Rules can invoke PDF generation and attach it to emails:

Pdf.generate_from_template('Template name', locals: { var: value })

From scripts

Only when the script runs on the local server (not remotely) does it have access to the application and can use Pdf.generate_from_template. In remote execution, the script does not have access to PDF templates.

Relationship with other modules

  • Rules: Can generate PDFs from templates and attach them to emails
  • Permissions: The "PDF Template" resource has read, edit, and delete permissions by role