Skip to content

PDF templates (creation)

Why this matters

PDF templates are the pre-built documents that produce your quotes, invoices, representation letters, receipts, proofs. As an administrator, you create and maintain them. User-side usage is covered in PDF templates (usage).

Create a template

  1. Sidebar → SettingsPDF templatesCreate.
  2. Fill in:
  3. Name ("Standard ES quote", "Detailed EN invoice", "FR representation letter").
  4. Module it's generated on (Quotes, Invoices, Cases, etc.).
  5. Main language of the template.
  6. Save and enter the editor.

Editor structure

The template editor has three areas:

  • Header — appears on every page, typically your logo and practice info.
  • Body — the main content with dynamic tokens.
  • Footer — page number, legal address, etc.

Each area is edited with rich HTML (visual editor or code).

Dynamic tokens

To insert record data:

  • {{applicant_name}} — inserts the applicant name.
  • {{case_folio}} — case folio.
  • {{date}} — current date.
  • {{line_items_table}} — table with the quote/invoice line items (special for modules with line items).
  • {{total}} — document total.

The full token list depends on the module. Editor → Insert token shows the available ones.

Screenshot: template editor with tokens inserted in the body

BLOCK_DATA and conditional blocks

To show/hide sections based on content:

  • {{#if has_discount}} ... {{/if}} — only if there's a discount.
  • {{#each line_items}} ... {{/each}} — repeats per line item.

These blocks are processed at PDF generation time.

Custom CSS

Each template can have its own CSS for styles:

  • Typography.
  • Colors.
  • Margins.
  • Boxes, lines, separators.

Editor → Custom CSS tab. Careful: mPDF (the PDF engine) has limitations — not all CSS3 works. Test before publishing.

Import from Vtiger

If you're coming from Vtiger, there's an importer command to bring legacy templates over. Ask your technical administrator: vtiger:backfill-pdf-templates. Tokens are converted to [token] automatically; some [TODO:vtiger:X] markers are left for manual review.

Test the template

Before publishing:

  1. Preview with a sample record.
  2. Verify every token substitutes correctly.
  3. Review format at different content sizes (quote with 1 line item vs. 30).

Associate templates with modules

For the template to appear as an option to the user:

  1. Associations tab → add the modules where it'll be available.
  2. Mark as default for one of the modules if you want it suggested.

Watch out for

  • mPDF has quirks. CSS attribute selectors like table[border="0"] are ignored. Use standard class or ID selectors. Some legacy HTML elements (<font>, inline attributes) are rewritten internally — that's documented in docs/PDF_RENDER_*.
  • Don't modify a template in production without testing. A bad template can produce PDFs that break the conversation with the client.
  • Version your critical templates. There's a change history table — use it. Before publishing big changes, export the current version as a backup.

Where to next