Document print templates
On this page
Document templates generate PDF output from your POS. When triggered, the PDF opens in the browser print dialog, where staff can send it to any connected printer.
Use document templates for output that needs precise layout control — invoices, packing slips, quotes, gift receipts, or any printed document with multi-column structure, logos, or custom styling.
Prerequisites
- A POS Print Template record with Printer type set to
document - Familiarity with POS print templates and basic Liquid syntax
Template structure
Every document template must wrap all content in a {% pdf %} block. This block initialises the PDF and sets page properties.
liquid
{% pdf orientation: 'portrait', format: 'a4' %}
... template content ...
{% endpdf %}
Only one {% pdf %} block is allowed per template.
PDF configuration options
| Option | Values | Description |
|---|---|---|
orientation |
'portrait', 'landscape' |
Page orientation (default: 'portrait') |
format |
'a4', 'letter', 'legal', 'a3', 'a5' |
Page size (default: 'a4') |
unit |
'mm', 'pt', 'in', 'px' |
Measurement unit for coordinates (default: 'mm') |
How tags work
Each Liquid tag inside the {% pdf %} block maps to a method in the jsPDF library. Arguments are passed in the same order as the jsPDF API.
For example:
liquid
{% text 'Hello', 10, 20 %}
Calls:
javascript
doc.text('Hello', 10, 20)
Coordinates are measured from the top-left of the page in whatever unit you specify in the {% pdf %} tag.
Available tags
Text
| Tag | Description |
|---|---|
{% text value, x, y %} |
Draw text at position |
{% text_with_link text, x, y, url: 'https://...' %} |
Draw text with a clickable URL |
{% set_font family, style %} |
Set font family and style ('normal', 'bold', 'italic', 'bolditalic') |
{% set_font_size size %} |
Set font size in points |
{% set_text_color r, g, b %} |
Set text color (RGB 0–255) |
{% split_text_to_size text, max_width %} |
Split text to fit within a width |
Examples:
liquid
{% set_font 'helvetica', 'bold' %}
{% set_font_size 14 %}
{% set_text_color 0, 0, 0 %}
{% text 'Tax Invoice', 20, 20 %}
{% text current_order.reference, 190, 20, align: 'right' %}
Lines and shapes
| Tag | Description |
|---|---|
{% line x1, y1, x2, y2 %} |
Draw a straight line between two points |
{% rect x, y, width, height %} |
Draw a rectangle (stroke only by default) |
{% rect x, y, width, height, style %} |
Draw filled or stroked rectangle ('S' = stroke, 'F' = fill, 'FD' = fill and stroke) |
{% rounded_rect x, y, width, height, radius_x, radius_y, style %} |
Draw a rounded rectangle |
{% circle x, y, radius %} |
Draw a circle |
{% ellipse x, y, rx, ry %} |
Draw an ellipse |
{% triangle x1, y1, x2, y2, x3, y3 %} |
Draw a triangle |
Examples:
```liquid {# Horizontal rule } {% set_draw_color 200, 200, 200 %} {% set_line_width 0.3 %} {% line 20, 45, 190, 45 %}
{# Shaded header bar } {% set_fill_color 42, 67, 119 %} {% rect 0, 0, 210, 18, ‘F’ %} ```
Color and style
| Tag | Description |
|---|---|
{% set_draw_color r, g, b %} |
Set stroke color (RGB) |
{% set_fill_color r, g, b %} |
Set fill color (RGB) |
{% set_line_width width %} |
Set line thickness |
{% set_line_dash pattern, phase %} |
Set dash pattern for lines |
{% stroke %} |
Stroke the current path |
{% fill %} |
Fill the current path |
{% fill_stroke %} |
Fill and stroke the current path |
Pages
| Tag | Description |
|---|---|
{% add_page %} |
Add a new page |
{% set_page number %} |
Switch to a specific page |
{% delete_page number %} |
Delete a page |
Example — multi-page document:
liquid
{% pdf orientation: 'portrait', format: 'a4' %}
{% text 'Page 1 content', 20, 20 %}
{% add_page %}
{% text 'Page 2 content', 20, 20 %}
{% endpdf %}
Images
| Tag | Description |
|---|---|
{% add_image image_data, format, x, y, width, height %} |
Add an image to the document |
{% add_svg_as_image svg_string, x, y, width, height %} |
Render an SVG as an image |
Graphics state
| Tag | Description |
|---|---|
{% save_graphics_state %} |
Save the current drawing state |
{% restore_graphics_state %} |
Restore the previously saved state |
Document properties
| Tag | Description |
|---|---|
{% set_properties properties_hash %} |
Set PDF document properties (title, subject, author) |
Available variables
Document templates use the receipt context, giving access to:
| Variable | Description |
|---|---|
current_order |
The order being printed (items, totals, payments, contact, outlet, reference, etc.) |
current_outlet |
The POS outlet where the print was triggered |
current_store |
The store |
Sample: tax invoice
The following example produces a basic tax invoice with a header, line items table, and totals.
```liquid {% pdf orientation: ‘portrait’, format: ‘a4’, unit: ‘mm’ %}
{# Header background } {% set_fill_color 42, 67, 119 %} {% rect 0, 0, 210, 22, ‘F’ %}
{# Store name } {% set_font ‘helvetica’, ‘bold’ %} {% set_font_size 16 %} {% set_text_color 255, 255, 255 %} {% text current_store.name, 20, 14 %}
{# Invoice label } {% set_font ‘helvetica’, ‘normal’ %} {% set_font_size 11 %} {% text ‘TAX INVOICE’, 190, 14, align: ‘right’ %}
{# Reset to black text } {% set_text_color 0, 0, 0 %} {% set_font_size 10 %}
{# Reference and date } {% text current_order.reference, 20, 32 %} {% text current_order.ordered_at | date: “%d %b %Y”, 190, 32, align: ‘right’ %}
{# Divider } {% set_draw_color 200, 200, 200 %} {% set_line_width 0.3 %} {% line 20, 38, 190, 38 %}
{# Column headers } {% set_font ‘helvetica’, ‘bold’ %} {% text ‘Item’, 20, 46 %} {% text ‘Qty’, 140, 46, align: ‘right’ %} {% text ‘Total’, 190, 46, align: ‘right’ %} {% line 20, 50, 190, 50 %}
{# Line items } {% set_font ‘helvetica’, ‘normal’ %} {% assign y = 57 %} {% for item in current_order.items %} {% text item.product.name, 20, y %} {% text item.quantity | to_s, 140, y, align: ‘right’ %} {% text item.total_price | money, 190, y, align: ‘right’ %} {% assign y = y | plus: 7 %} {% endfor %}
{# Totals } {% line 20, y, 190, y %} {% assign y = y | plus: 7 %} {% text ‘Subtotal’, 140, y %} {% text current_order.subtotal | money, 190, y, align: ‘right’ %} {% assign y = y | plus: 6 %} {% text ‘Tax’, 140, y %} {% text current_order.tax | money, 190, y, align: ‘right’ %} {% assign y = y | plus: 6 %} {% set_font ‘helvetica’, ‘bold’ %} {% text ‘Total’, 140, y %} {% text current_order.total | money, 190, y, align: ‘right’ %}
{% endpdf %} ```
Set up the print action
To trigger document printing from a POS layout, use the print:template or print:receipt action with the SFID of your document template:
json
{
"action": "print:receipt",
"params": "order_sc_id={{ record.id }};print_template_sfid=YOUR_TEMPLATE_SFID"
}
Or to trigger explicitly by template:
json
{
"action": "print:template",
"params": "print_template_sfid=YOUR_TEMPLATE_SFID"
}
For full action reference, see POS print templates.
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.