Guide

Templates

Write a PDF template in Markdown or HTML, choose the CSS that styles it, and compile Markdown to HTML when you need more control.

On this page

Community

Markdown or HTML

Brevier reads two kinds of template. Both use the same {{ }} tags.

Format Good for File
Markdown letters, simple invoices, text with a few tables rechnung.md
HTML full control: several header rows, grids, custom blocks rechnung.html

Start in Markdown. When you need more control, turn it into HTML with brevier compile (see below) and keep working there.

Front matter

A Markdown template can start with a YAML block between two --- lines. Brevier reads its settings from there.

angebot.md
---
theme: print-base
style: angebot.css
page:
  size: A4
---

Text of the document …
Key Meaning
theme A built-in theme to use: print-base, web or din5008.
style A CSS file next to the template.
page Paper size, margins, headers and footers. See Page layout.
table A table built from a list in your data. See Tables.

An HTML template has no front matter. It names its theme in a <meta> tag inside <head>:

<meta name="brevier-theme" content="print-base">

For its own CSS, put a file with the same name next to it: rechnung.css next to rechnung.html.

Which CSS applies

Brevier looks for CSS in this order. The first match wins.

  1. --theme and --style on the command line
  2. theme and style in the front matter
  3. a CSS file with the template's name: rechnung.css next to rechnung.md

The theme comes first, and your own stylesheet comes after it. So your rules win over the theme's rules. You can pass --style more than once; a later file wins over an earlier one.

Built-in themes

Theme Use
print-base Plain rules for printed pages. The default for new templates.
web Styles for brevier html output shown in a web page.
din5008 The layout of a German letter or invoice: margins, the address field for a window envelope, the information block, fold marks and hole mark. The font comes with the theme. See the DIN 5008 values.

Compile a Markdown template to HTML

compile writes the HTML that a Markdown template compiles to:

brevier compile rechnung.md

This creates rechnung.html next to the Markdown file. The {{ }} tags stay in it, and the front matter becomes <link> and <meta> tags. It stops if the file exists already; add --force to replace it.

Compile is a one-way step. After it, you edit the HTML file, and the Markdown file is no longer used.

Preview in the browser

Preview templates in your browser with live reload:

brevier preview rechnung.html --data rechnung.json --open

preview watches the template, stylesheet and JSON data, reloading automatically whenever you save.

Import existing templates

If you have existing Word documents (.docx), JasperReports (.jrxml) or BIRT reports (.rptdesign), import turns them into a Brevier template, CSS stylesheet and JSON Schema:

brevier import rechnung.docx -o templates/rechnung

Import a template lists what the import converts and names, and shows how to replace your render call.