Create a template
1
Open PDF templates
On a collection, open PDF templates → New template.
2
Write the template
HTML for the content, CSS for the look, and optionally a Header and Footer repeated on every page. Use Insert to add a field of the record or a ready-made snippet at the cursor.
3
Preview it
Open Preview and choose Sample data or A record. Turn on Live to update the PDF as you type.
4
Save
Every save is a new version and becomes the one in use. Versions lists them; open an old one or make it active again.
The editor
- The settings on the left are grouped (template, page, layout, document, images, fonts); closed groups show a summary.
- The code editor highlights HTML, CSS and the template tags, and suggests as you type inside
{{ }}: the record’s fields, fields of related records (record.customer.), related lists (record.children.), the fields of a loop’s items, filters with their arguments (after|), blocks (#if,#each…), images, anddocument/page/toc. Press Ctrl+Space to ask for suggestions. - Problems are underlined in the code and listed under it; click one to jump to it. Each code tab shows how many it has.
- Ctrl+S (⌘S) saves. Each tab (HTML, Header, Footer, CSS) keeps its own undo history.
- Closing the editor or opening another template with unsaved changes asks first.
- Duplicate starts a new template from an existing one.
Template syntax
Values
Values are always inserted as text, never as HTML, and are never read as template code: a value containing
{{…}} prints as written. A missing field, null or an empty value prints nothing.
QR code fields give an embedded image source: <img src="{{record.qr}}">. Password fields are never available.
Images and fonts
PDFs never load files from the internet: everything a document shows is embedded in it.- Images: PNG, JPEG, GIF, WebP or SVG, up to 5 MB each. Fonts: TTF, OTF, WOFF or WOFF2, up to 5 MB each. A document embeds at most 10 MB of images and fonts.
- The file type is checked from the file itself, not its name. A file that isn’t an image (or is another project’s) shows as an empty image.
| imageon a field with several files uses the first.- Use
background-image: url("{{assets.paper}}")in the CSS for a background image.
Headers, footers and page numbers
The editor’s Header and Footer tabs hold template HTML repeated on every page. They can use everything a template can (record fields, filters, conditions,{{assets.logo}}), plus the page number:
- The header sits inside the top margin and the footer inside the bottom margin: set margins tall enough (for example 30 mm with a logo).
- The template’s CSS applies to them. Uploaded fonts don’t (the system’s fonts are used, including Noto Arabic on Bludia’s servers).
{{page.number}}and{{page.total}}only work in the header and footer.
Page {page} of {pages} or صفحة {page} من {pages}, with Western or Arabic digits.
Backgrounds
In Page layout, Background sets a colour and/or an image (one of the template’s images, PNG or JPEG) for every page, margins included. The image can fill the page, fit inside it, or be stretched to it. For a watermark (for example DRAFT or PAID), use a fixed element: it repeats on every page.Page breaks
By default, table rows are never split across pages, table headers repeat on every page, headings stay with what follows, and long words and links wrap. Turn any of these off in Page layout. In the template:Table of contents
Put{{toc}} where the table of contents goes. It lists the document’s headings (h1 to h3 by default; change it with Table of contents in Page layout) with the page each one is on, as clickable links. Page numbers use Arabic digits when the page numbers do.
toc-exclude (or inside an element with it) are left out. Restyle it with the classes bludia-toc-entry, bludia-toc-l1 … bludia-toc-l6, bludia-toc-title, bludia-toc-leader and bludia-toc-page.
QR codes, barcodes and charts
- Barcode types:
code128(default),code39,ean13,ean8,upca,upce,itf14,i25,codabar. A value the type can’t encode (letters in an EAN-13) gives an empty image. - Charts:
"bar","line"or"pie", then the field for the labels and the field for the numbers, and optionally colours:chart: "pie", "category", "amount", "#2563eb,#16a34a". Values with the same label are added up exactly. Charts fill the width of their container; set the height in CSS (.bludia-chart { height: 70mm; }). - QR codes, barcodes and charts are drawn as vectors: sharp at any size.
Links and bookmarks
Links (<a href="https://…">, mailto:, tel:) are clickable in the PDF, and <a href="#totals"> jumps to the element with id="totals". Other kinds of links are removed.
Headings (h1–h6) become the PDF’s bookmarks, so readers can jump between sections. Turn this off with Bookmarks from headings in Page layout ("bookmarks": false).
Language and direction
Set Language in the editor (for example Arabic) and the document is written right to left, with an Arabic font that looks the same wherever the PDF is generated. Direction overrides it. Two Arabic fonts are always available, whatever the language:"Noto Sans Arabic" and "Noto Naskh Arabic". Add one after your Latin font so Arabic text uses it:
Conditions
Conditional formatting: put a condition inside an attribute.
Repeating content
record.children.KEYlists the records of another collection that point at this record.KEYis that collection’s name or slug.{{else}}inside a loop shows when the list is empty.- Inside a loop:
@number(1, 2, …),@index(0, 1, …),@first,@last,@count. - Loops nest (
{{#each line.children.parts as part}}). Inside a loop,recordand the outer loop’s item stay available. {{#each list}}withoutasnames the itemthis.- A many-to-many relation field is a list too:
{{#each record.tags as tag}}{{tag}} ({{tag.colour}}){{/each}}.
Filters
Write{{ value | filter: argument, argument }}, and chain them: {{record.total | currency: "SAR" | default: "—"}}. Formatting filters keep empty values empty, so default can follow any of them.
Numbers are exact: totals and rounding never pass through floating point. Rounding is half up (
1234.565 → 1,234.57). Date formats use yyyy, MM, MMM, dd, EEE, HH, hh, mm, ss, a. Date-only values never shift between timezones.
What a template can read
A document reads only what its template mentions, and only what the person generating it may see:- Related collections and child lists follow the same permissions and row rules as everywhere else in Bludia. Records someone can’t see are left out of their documents, as if they didn’t exist. Deleted records are never included.
- Password fields are never available.
- Computed fields show their current values, as on the record page.
A document over a limit is not generated. The error says which list is too long. Split it into smaller documents.
Problems in a template
The editor checks the template as you type and lists problems by line: tags it can’t read, blocks that are never closed, unknown filters, fields or related collections that don’t exist, password fields, images the template doesn’t have, files from other sites that won’t load, and scripts that won’t run. Click a problem to jump to it. A problem never stops a template from saving or rendering: an unreadable tag is printed as written, so it is visible in the PDF.Page settings
Invalid values fall back to the default.
What a template cannot do
Templates are markup only. Scripts, event handlers (onload, onerror, …), frames, forms and page redirects do not run in the renderer. It loads nothing from the network: images and stylesheets from other sites (<img src="https://…">, @import) are not loaded. Upload images and fonts to the template instead. Links (<a href="https://…">) stay clickable in the PDF.
Saved documents
Download makes a PDF on the spot. Save (on the record page) makes a PDF that is kept:- it is generated in the background and stored with the project’s files;
- it can be attached to one of the record’s file fields (choose Attach to): the field then holds the PDF;
- it records which template version made it, and its SHA-256 fingerprint;
- it has a permanent identifier and a public verification page.
Verification
Every saved document has a page athttps://<your Bludia address>/verify/<identifier>. Anyone with the link sees who issued the document, which template, when, and whether it was revoked. They never see the record’s data. They can also upload their copy: it matches only if it is exactly the file that was issued, so any change is detected.
Print the link on the document itself, usually as a QR code:
{{document.id}} shows a placeholder.
From a function
A function can make a saved document with the Generate a PDF step: for example, confirm a booking, then save its confirmation PDF into the booking and show the verification link.
Later steps can read
steps.pdf.id and steps.pdf.verify_url, for example in the result message.
- The PDF is made right after the function finishes, as the person (or the system) the function runs as, so it reads only what they may read.
- If the function stops (a guard, an error) or is a dry run, no document is made.
- Storing the PDF in the record is not a new change for the function: a function that runs when its records change does not run again because of it.
- A template that a published function uses cannot be deleted.
