docs

Template format reference (v1)

A Liuska template is a JSON file that describes the page, a header and footer band, and positioned elements whose text can bind to your data with {{ }}. The engine renders it straight to PDF, with no HTML or browser involved.

Contents: Skeleton · Units & coordinates · Page · Fonts · Styles · Header & footer · Elements · Bindings & filters · Tables · Charts · Pagination & anchors · Repeating elements · PDF standards · Sample data · Pre-v1 templates

Skeleton

{
  "$schema": "../schema/template.v1.schema.json",
  "version": 1,
  "name": "Monthly sales report",
  "page": {
    "size": "A4",
    "orientation": "portrait",
    "margins": { "top": 40, "right": 40, "bottom": 40, "left": 40 }
  },
  "locale": "fi-FI",
  "fonts": [{ "family": "Inter", "style": "regular", "src": "fonts/Inter-Regular.ttf" }],
  "defaultStyle": { "fontSize": 10, "color": "#222222" },
  "styles": { "h1": { "fontSize": 20, "bold": true } },
  "header": { "height": 50, "elements": [] },
  "footer": { "height": 30, "elements": [] },
  "elements": []
}
Field Required Description
version yes Always 1. A file without it is rejected (see pre-v1 templates).
name Display name, used by the designer and GET /api/templates.
page yes Size, orientation and margins. See Page.
units Always "pt" (the default). Shown here for clarity.
locale Number, currency and date formatting: en-US (default), fi-FI, de-DE, sv-SE.
fonts Extra font files. See Fonts.
defaultStyle Style applied to every element.
styles Named styles. Elements reference one with "style": "h1".
header, footer Bands repeated on every page.
repeatGap Points kept between a repeated element and the flowing content on the pages where it repeats. Default 8.
pdf PDF/A and PDF/UA conformance, tagging, document metadata and attachments. See PDF standards and metadata.
elements yes Body elements.
sampleData, sampleDataFile Data used for the designer's preview and when no -d is given.

Keys that start with x- or _ are reserved for tool metadata, and the renderer ignores them. Any other unknown key is a schema error, so typos such as fontsize are caught.

Units and coordinates

Page

"page": { "size": "A4", "orientation": "landscape", "margins": { "top": "15mm", "right": "12mm", "bottom": "15mm", "left": "12mm" } }

Fonts

Liuska ships with a bundled sans-serif font, so output looks the same on every machine and never depends on whatever fonts happen to be installed. To use your own fonts:

"fonts": [
  { "family": "Inter", "style": "regular", "src": "fonts/Inter-Regular.ttf" },
  { "family": "Inter", "style": "bold", "src": "fonts/Inter-Bold.ttf" }
],
"defaultStyle": { "fontFamily": "Inter" }

style is one of regular, bold, italic or bold-italic, and bold: true / italic: true pick the matching face. src is resolved relative to the template file, then against the engine's font directories (FontDirs). Under liuska serve, every file a template names (fonts, images, snippets, sample data) must stay inside the templates directory or an allowed directory. See security.md. Fonts are parsed once per engine, and only the glyphs a document uses are embedded, which keeps files small.

Formats. Both TrueType (.ttf, glyf outlines) and OpenType/CFF (.otf, PostScript outlines) work, so brand fonts that ship only as OTF can be used as they are. CFF fonts are embedded as subset CID-keyed CFF (FontFile3), with unused glyphs and subroutines removed, so a CJK font of 16 MB adds a few hundred KB at most. Not supported: font collections (.ttc/.otc), WOFF/WOFF2 web fonts and variable fonts (CFF2, or picking a named instance from a variable .ttf). Use a static instance instead.

Fallback fonts for missing characters

When a character isn't in an element's font (a symbol, a CJK name in a Latin report, a € in an old brand font), Liuska tries the families in fontFallback in order, glyph by glyph, and then the bundled font:

"fonts": [
  { "family": "Brand", "src": "fonts/Brand-Regular.otf" },
  { "family": "Noto Symbols", "src": "fonts/NotoSansSymbols2-Regular.ttf" },
  { "family": "Noto CJK", "src": "fonts/NotoSansCJKjp-Regular.otf" }
],
"fontFallback": ["Noto Symbols", "Noto CJK"],
"defaultStyle": { "fontFamily": "Brand" }

Kerning

Pair kerning from the font (the OpenType GPOS kern feature, or the older kern table) is applied by default, so "AVATAR" or "Tower" look as the type designer intended. It applies to measuring, wrapping, the PDF and PNG previews. The bundled Go font has no kerning data, so templates that use it look the same as before. Turn kerning off with "kerning": false at the top level of the template. Ligatures and other OpenType substitutions are not applied.

Styles

Style properties can be written inline on any element, in defaultStyle, in named styles, and in table row, header and column styles:

Property Type Notes
fontFamily string Bundled default or a family from fonts
fontSize number Points
bold, italic boolean
color #rgb, #rrggbb, #rrggbbaa Text color
align left | center | right Horizontal text alignment
valign top | middle | bottom Vertical text alignment
lineHeight number Multiplier, e.g. 1.3
fill color Background or fill
stroke, strokeWidth color, number Outline or line
radius number Corner radius
padding number or {top,right,bottom,left}
opacity 0–1

Precedence, from lowest to highest: defaultStyle, then the named style, then inline properties.

"styles": { "label": { "fontSize": 7, "bold": true, "color": "#6b7280" } },
"elements": [ { "type": "text", "style": "label", "color": "#111111", "content": "BILL TO", "x": 40, "y": 120, "width": 200, "height": 10 } ]
"header": {
  "height": 50,
  "elements": [
    { "id": "logo", "type": "image", "src": "logo.png", "x": 0, "y": 0, "width": 100, "height": 32 },
    { "id": "title", "type": "text", "style": "h1", "content": "{{report.title}}", "x": 120, "y": 0, "width": 400, "height": 24 }
  ]
},
"footer": {
  "height": 24,
  "elements": [
    { "id": "pageNo", "type": "text", "align": "right", "content": "Page {{page}} of {{pages}}", "x": 315, "y": 8, "width": 200, "height": 12 }
  ]
}

Bands are drawn on every page. Their height is taken out of the body area on every page. {{page}} and {{pages}} work anywhere, but they are mostly used here.

To repeat something that belongs in the body rather than the band, such as a KPI strip under the header, set repeat on it instead: see Repeating elements. Elements inside the bands repeat already and ignore repeat.

Elements

Every element has these fields:

Field Description
id Unique id. Other elements need it to anchor to this one; the designer always sets one.
type rect, line, text, image, table, chart, group (alias snippet) or pageBreak
x, y, width, height Number (pt) or dimension string
style Name of a named style
style properties Inline, see Styles
anchors Attach edges to other elements, see Pagination & anchors
visibleIf Data path. The element is drawn only when the value is truthy, i.e. not missing, null, false, 0, "" or [].
rotation Degrees
repeat "all" / true, "following", or "none" / false (default). Draw a top-level body element on other pages too; see Repeating elements.
alt, role Tagged PDF / PDF/UA: alternative text (images, charts, figure groups) and the structure tag (H1...H6, P, Figure, artifact, ...). See PDF standards and metadata.

rect

{ "id": "box", "type": "rect", "x": 40, "y": 100, "width": "100%", "height": 40, "fill": "#f1f5f9", "stroke": "#cbd5e1", "strokeWidth": 0.5, "radius": 4 }

line

Draws from (x, y) to (x + width, y + height), so height: 0 gives a horizontal rule.

{ "id": "rule", "type": "line", "x": 40, "y": 140, "width": "100%", "height": 0, "stroke": "#999999", "strokeWidth": 0.5, "dash": [3, 2] }

text

{ "id": "addr", "type": "text", "content": "{{customer.name}}\n{{customer.street}}\n{{customer.city}}", "x": 40, "y": 120, "width": 220, "height": 48, "overflow": "grow" }

Text wraps inside the box. \n starts a new line. overflow decides what happens when the text doesn't fit:

Line breaking. Lines break at spaces and tabs. Inside a word, a line can also break after a hyphen, dash or slash (well- / known, path/ / to), but not between digits (2026-11-29 stays together), at a soft hyphen \u00ad (drawn as - only where the line breaks, invisible elsewhere), and at a zero-width space \u200b (invisible). Put soft hyphens into long compound words ("Rechnungs\u00adnummer") or zero-width spaces into long identifiers where a break is acceptable. A word is broken between two letters only when it is wider than the whole line on its own. No hyphen is added then, and there is no dictionary hyphenation. A no-break space \u00a0 keeps two words together, as in "10\u00a0kg".

image

{ "id": "logo", "type": "image", "src": "logo.png", "x": 40, "y": 40, "width": 120, "height": 36, "fit": "contain" }

src can be a path relative to the template, a data:image/png;base64,… URI, or a binding such as "{{company.logoUrl}}" that resolves to either. fit is contain (default), cover or fill.

SVG images (.svg/.svgz files, data:image/svg+xml URIs, or a binding that resolves to inline <svg …> markup) are drawn as vector paths with real, searchable text in the template's fonts, not rasterised. That is the way to bring in static D3 output and icons; see SVG images for what is supported.

group / snippet

{ "id": "addressBlock", "type": "group", "x": 40, "y": 120, "width": 240, "height": 80, "children": [
  { "type": "text", "style": "label", "content": "BILL TO", "x": 0, "y": 0, "width": 240, "height": 10 },
  { "type": "text", "content": "{{customer.name}}", "x": 0, "y": 12, "width": 240, "height": 14 }
] }

Child coordinates are relative to the group. Set snippetPath: "parts/address.json" instead of children to pull in the elements of another template file, which lets several templates share a block.

pageBreak

{ "type": "pageBreak" }

Moves all body elements that come after it in elements onto a new page.

Bindings and filters

A binding is a {{path}} inside content (and inside image src):

Path Resolves to
{{customer.name}} Nested object field
{{items[0].description}} Array index
{{seller.address[1]}} Index into an array of strings
{{page}}, {{pages}} Current page number and total page count
{{now | date:"2006-01-02"}} Render time

A missing path renders as an empty string. liuska validate -d data.json reports missing paths, and liuska render --strict turns them into errors.

Filters are applied with a pipe and can be chained, e.g. {{ value | number:2 | default:"—" }}:

Filter Example en-US fi-FI
number:N {{ 1234.5 | number:2 }} 1,234.50 1 234,50
currency:"EUR" {{ 1234.5 | currency:"EUR" }} €1,234.50 1 234,50 €
percent:N {{ 0.084 | percent:1 }} 8.4% 8,4 %
compact {{ 1234567 | compact }} 1.2M 1,2 milj.
date:"layout" {{ "2026-11-28" | date:"02.01.2006" }} 28.11.2026 28.11.2026
upper / lower {{ name | upper }} ACME ACME
default:"text" {{ ref | default:"—" }} — when empty

Tables

The table is the main element for data-driven documents. It binds to an array of objects, works out its columns, and flows across as many pages as it needs.

{
  "type": "table", "id": "sales", "x": 40, "y": 120, "width": "100%",
  "data": "report.rows",
  "columns": [
    { "key": "region", "header": "Region", "width": "auto", "align": "left" },
    { "key": "revenue", "header": "Revenue", "width": 80, "align": "right", "format": "currency:\"EUR\"" }
  ],
  "headerStyle": { "bold": true, "fill": "#f0f0f0" },
  "altRowStyle": { "fill": "#fafafa" },
  "cellPadding": 4,
  "borders": { "outer": { "color": "#999999", "width": 0.5 }, "horizontal": { "color": "#dddddd", "width": 0.5 }, "vertical": null },
  "repeatHeader": true,
  "totals": { "region": "Total", "revenue": "sum" }
}

Rows: data

data is a path (without braces) to an array of objects, such as "items" or "report.rows". An array of arrays, whose first row is the header, also works.

Columns: pick exactly one way

1. Fixed: columns. Use this when you know the columns at design time, as on an invoice.

2. Data-driven: columnsFrom. This is the main reason to use Liuska for reports. The column definitions come from the data, so one template handles "January–March" and "January–December", or any set of products:

{ "type": "table", "id": "sales", "data": "report.rows", "columnsFrom": "report.columns", "x": 30, "y": 134, "width": "100%" }
{
  "report": {
    "columns": [
      { "key": "region", "header": "Region", "width": 82 },
      { "key": "2026-01", "header": "Jan", "width": 46, "align": "right", "format": "number:0" },
      { "key": "2026-02", "header": "Feb", "width": 46, "align": "right", "format": "number:0" },
      { "key": "total", "header": "Total", "width": 62, "align": "right", "format": "number:0" }
    ],
    "rows": [
      { "region": "Uusimaa", "2026-01": 8773.18, "2026-02": 9137.71, "total": 17910.89 }
    ]
  }
}

Each column definition has the same shape as an entry in columns. Your backend decides which months, products or KPIs to show, and the template decides how they look.

3. Automatic: autoColumns: true. The columns are the keys of the first row, in JSON key order, and each header is its key. This fits CSV input well, since the CSV header becomes the table header. See examples/sales-report-auto.

Column fields

Field Description
key Field in the row; may be a dot path ("customer.name")
header Header text (defaults to the key)
width 80 (pt), "20%" (of table width), "auto" (measured from content, default; see Column widths), "*" / "2*" (share of the space left after fixed and auto columns)
align left (default) | center | right
format Filter syntax without the |: currency:"EUR", number:0, percent:1, date:"02.01.2006". Applies to cells and totals.
headerStyle, style Style overrides for this column's header cell and body cells, e.g. { "bold": true }

Inside a JSON string, the quotes in a format need escaping: "format": "currency:\"EUR\"".

Table styling

Field Description
headerStyle Header row style
rowStyle Body row style
altRowStyle Every second row (zebra), on top of rowStyle
cellPadding Number or {top,right,bottom,left}
borders outer, horizontal, vertical: each { "color", "width" }, or null for none
repeatHeader Repeat the header row on each page (default true). A table itself cannot repeat; to keep other content on every page above the table, see Repeating elements.

Totals

totals adds a row after the last data row. It is keyed by column key:

"totals": { "region": "Total", "units": "sum", "revenue": "sum", "margin": "avg" }

Each value is sum, avg, min, max, count, or any other text, which is printed as is. Aggregates are formatted with the column's format.

Totals with dynamic columns. totals is part of the template, so with columnsFrom it can only name keys you know in advance, such as the label column and a total column. For per-month totals in a columnsFrom table, either compute them in the backend and print them with text elements anchored under the table, or use autoColumns (whose keys come from a known export format) and list them.

Column widths and shrink-to-fit

Auto columns start at their content width: the widest cell, header or total. If the table is wider than its box, what happens depends on scalingWidth:

minFontSize sets a floor for shrink. If the table would need a smaller font, it is scaled only down to minFontSize, and the remaining overflow is handled by wrapping its auto and * columns, using the min-content rule above. Without a floor, a 40-column table gets unreadably small:

{ "type": "table", "data": "report.rows", "columnsFrom": "report.columns", "x": 30, "y": 134, "width": "100%",
  "scalingWidth": "shrink", "minFontSize": 6 }

Charts

A chart element draws a bar, line, area, pie, donut or scatter chart from your data. Charts are vector: bars, lines and slices are PDF paths, and labels are real text in the template's fonts. They stay sharp at any zoom, add only a few KB, and their text can be searched and copied. Like tables, charts are data-driven: they bind to an array of rows, and the data can even decide which series are drawn.

{
  "type": "chart", "id": "rev", "x": 40, "y": 140, "width": "100%", "height": 220,
  "chart": {
    "kind": "bar",
    "data": "report.byMonth",
    "category": { "key": "month", "format": "date:\"Jan\"" },
    "series": [ { "key": "revenue", "label": "Revenue {{report.year}}", "format": "currency:\"EUR\"" } ],
    "title": "Revenue {{report.year}}"
  }
}
{ "report": { "year": 2026, "byMonth": [
  { "month": "2026-01-01", "revenue": 770194.55 },
  { "month": "2026-02-01", "revenue": 860888.10 },
  { "month": "2026-03-01", "revenue": 935209.42 }
] } }

The usual element fields apply: id, x, y, width, height, anchors, visibleIf, style and inline style properties. Font properties (fontFamily, fontSize, bold, color) style all text in the chart: title, tick labels, legend and data labels. fill, stroke, strokeWidth, radius and padding style the chart's outer box, so a white card with a thin border is "fill": "#ffffff", "stroke": "#e2e8f0", "strokeWidth": 0.75, "radius": 6, "padding": 10. All chart settings sit in the nested chart object, so they can't collide with x, y or the style properties.

Bindings ({{report.year}}, with filters) work in the chart title, in series labels and in axis labels (category.label, axes.*.label).

Examples: examples/sales-report (a combo chart and a horizontal bar chart above a table, and a donut anchored under it) and examples/sales-dashboard (a one-page dashboard with KPIs and four charts).

Kinds

kind Draws category is Notes
bar Vertical bars, one group per category The x axis stacked, horizontal, barGap
line One line per series The x axis smooth, markers, lineWidth
area Lines with the area below filled The x axis stacked, smooth
pie Slices of the first series (extra series are ignored with a warning) The slice label Values ≤ 0 are left out
donut A pie with a hole, first series only The slice label donutHole
scatter One point per row and series The numeric x value markers; x axis ranges like a value axis

Data and category

data is a path (without braces) to an array of row objects, one per category: a month, a region, a slice. An array of arrays also works; its first row is the header, as with tables.

category says which key of each row is the category:

Field Description
key Key of the category in each row (required). May be a dot path within the row.
label Title of the category axis, e.g. "Month". Bindings allowed. axes.x.label overrides it.
format How category values are printed, in filter syntax without the |, e.g. date:"Jan" (ISO date to a localized month name) or number:0. Empty means as is.

Categories are drawn in row order, so sort the rows in your backend (largest region first, months in calendar order).

Series: pick exactly one way

As with table columns, there are three ways to say what is plotted. Use exactly one of them; the schema and liuska validate reject a chart that sets two. The schema also asks for one of them to be set. The engine itself is lenient and treats a chart with none of the three as autoSeries: true, but writing it out keeps the template self-explanatory.

1. Fixed: series. You know the series at design time:

"series": [
  { "key": "revenue", "label": "Revenue", "color": "#2563eb", "format": "currency:\"EUR\"" },
  { "key": "cost", "label": "Cost", "color": "#94a3b8", "format": "currency:\"EUR\"" }
]

2. Data-driven: seriesFrom. A data path to an array of series definitions, in the same shape. Your backend decides how many lines or bar groups there are, e.g. one line per region the user selected:

"chart": { "kind": "line", "data": "dashboard.monthly", "category": { "key": "month", "format": "date:\"Jan\"" }, "seriesFrom": "dashboard.regionSeries" }
{ "dashboard": {
  "regionSeries": [
    { "key": "uusimaa", "label": "Uusimaa", "color": "#2563eb" },
    { "key": "lappi", "label": "Lappi", "color": "#dc2626" }
  ],
  "monthly": [
    { "month": "2026-01-01", "uusimaa": 218956, "lappi": null },
    { "month": "2026-04-01", "uusimaa": 274893, "lappi": 40180 }
  ]
} }

3. Automatic: autoSeries: true. Every numeric key of the first row except category.key, in JSON key order, becomes a series. The label is the key and the color comes from the palette. This fits CSV input ({ "rows": [...] }), where the CSV header names the series.

Series fields

Field Default Description
key Key of the value in each row (required). May be a dot path within the row.
label the key Name in the legend. Bindings allowed: "{{report.previousYear}}"
color next palette color #rrggbb
format value as is Format of this series' values in data labels, e.g. currency:"EUR", number:0, percent:1
kind the chart kind bar, line or area: per-series override for combo charts
axis left left or right (secondary axis)

Chart options

Option Default Description
kind bar, line, area, pie, donut or scatter (required)
data Data path to the rows (required)
category { key, label, format } (required)
series / seriesFrom / autoSeries Exactly one, see above
stacked false bar/area: stack the series instead of drawing them side by side (bars) or overlapping (areas). In combo charts only series of the same kind stack with each other.
horizontal false bar: horizontal bars; categories run down the left side
title none Title at the top of the box. Bindings and filters allowed: "Revenue {{report.year}}"
legend bottom top, bottom, right or none. With a single series the default is none, except for pie and donut, which always list their slices.
axes y, y2 and x axis settings, see Axes
dataLabels false Labels on bars, points and slices: false, "value" (formatted with the series format), "percent" (share of the category's total; pie/donut: of all slices), "both". true means "value", except for pie and donut, where it means "both".
palette ["#2563eb", "#16a34a", "#f59e0b", "#dc2626", "#7c3aed", "#0891b2"] Colors given to series (pie/donut: slices) in order, repeating when there are more series. A series color wins.
smooth false line/area: monotone cubic curves through the points. They never overshoot, so a curve doesn't dip below zero between two positive points.
markers true line/scatter: a marker at each point
lineWidth 1.5 Line width in points
barGap 0.2 Fraction of each category band left empty (0 = bars touch, must be below 1)
donutHole 0.55 donut: inner radius as a fraction of the outer radius
emptyText "No data" Drawn in the middle of the box when data is missing or an empty array

A bar chart with each option written out:

{
  "type": "chart", "id": "regions", "x": 40, "y": 400, "width": 515, "height": 200,
  "fontSize": 7, "color": "#334155", "fill": "#ffffff", "stroke": "#e2e8f0", "strokeWidth": 0.75, "radius": 6, "padding": 10,
  "chart": {
    "kind": "bar",
    "data": "report.byRegion",
    "category": { "key": "region", "label": "Region" },
    "series": [
      { "key": "online", "label": "Online", "format": "number:0" },
      { "key": "stores", "label": "Stores", "format": "number:0" }
    ],
    "stacked": true,
    "horizontal": false,
    "title": "Revenue by region, {{report.period}}",
    "legend": "right",
    "axes": {
      "y": { "label": "EUR", "min": 0, "max": null, "format": "number:0", "gridlines": true, "ticks": 5 },
      "x": { "label": "", "labelRotation": 45 }
    },
    "dataLabels": false,
    "palette": ["#1d4ed8", "#93c5fd"],
    "barGap": 0.25,
    "emptyText": "No sales in this period"
  }
}

Axes

axes has up to three entries. Pie and donut have no axes and ignore them.

Axis What it is
y The primary value axis, on the left. With horizontal: true it is the value axis along the bottom.
y2 The secondary value axis on the right, used when any series has "axis": "right"
x The category axis along the bottom (down the left side for horizontal bars). For scatter it is a numeric axis.
Field Default Applies to Description
label none all Axis title. Bindings allowed. On x it overrides category.label.
min, max null (auto) value axes, scatter x Fix one or both ends of the range
format value as is all Tick label format, e.g. number:0, currency:"EUR", percent:0
gridlines true for y, else false all Gridlines at the ticks
ticks 5 value axes, scatter x Approximate number of ticks
labelRotation 0 x only 0, 45 or 90 degrees

Automatic ranges. Without min/max the range comes from the data and is widened to "nice" ticks: steps of 1, 2 or 5 × 10ⁿ, close to the ticks count. Bar and area ranges always include 0, so bars start at the zero line. Line and scatter ranges follow the data and need not include 0. Negative values work: bars go down from the zero line, and the axis extends below 0.

Crowded category labels. If the category labels would overlap, the engine skips some of them (every second, every third, …) so the rest stay readable. Rotating them with labelRotation: 45 or 90 fits more labels; a horizontal bar chart is often the better choice for long names such as product titles.

Combo charts and the secondary axis

A series' kind overrides the chart's kind, so one chart can mix bars, lines and areas. Only bar, line and area mix. Pie, donut and scatter can't be combined with anything, and the schema and validator reject a pie, donut or scatter chart whose series set a kind.

A series with "axis": "right" is measured against axes.y2 on the right instead of axes.y, which you need when the units differ, such as a margin percentage next to euros. Each axis computes its own range from its own series.

Revenue bars for this year, a line for last year on the same axis, and the margin % on the right axis (examples/sales-report):

"chart": {
  "kind": "bar",
  "data": "report.byMonth",
  "category": { "key": "month", "format": "date:\"Jan\"" },
  "series": [
    { "key": "revenue", "label": "{{report.year}}", "color": "#2563eb", "format": "number:0" },
    { "key": "lastYear", "label": "{{report.previousYear}}", "kind": "line", "color": "#94a3b8", "format": "number:0" },
    { "key": "margin", "label": "Margin %", "kind": "line", "axis": "right", "color": "#f59e0b", "format": "percent:1" }
  ],
  "legend": "top",
  "axes": {
    "y": { "label": "EUR", "min": 0, "format": "number:0" },
    "y2": { "label": "Margin", "min": 0.28, "max": 0.36, "format": "percent:0", "ticks": 4 }
  }
}

With stacked: true in a combo chart, only series of the same kind stack with each other: the bars form one stack, and a line over them is drawn at its own values (handy for a target or a total).

Draw order, from bottom to top: gridlines, areas, bars, lines, markers, data labels, legend. Lines are never hidden behind bars, and labels are never hidden behind lines.

Dynamic series

seriesFrom is the chart counterpart of a table's columnsFrom. The template decides how the chart looks, and the data decides what is in it:

Each entry in the array has the series fields (key, label, color, format, kind, axis). Rows that don't have a series' key count as missing values, see Missing and null values. An empty seriesFrom array draws emptyText, like empty data. liuska validate -d data.json reports a missing data path and series values that aren't numbers.

autoSeries: true is the zero-configuration variant: the numeric keys of the first row are the series, in key order. A key that holds text (such as a label column) is skipped automatically, so only numbers are plotted.

Formatting and locale

Every number in a chart goes through the same filters as text and tables, written without the |:

Where Field Example
Tick labels axes.y.format, axes.y2.format, axes.x.format "number:0", "percent:0", "currency:\"EUR\""
Data labels series format "number:0"
Category labels category.format "date:\"Jan\"", "number:0"
Title, series and axis labels title, series label, axis label, with bindings "Revenue {{report.total | currency:\"EUR\"}}"

The template locale sets the separators, so with "locale": "fi-FI" a tick reads 300 000 and a data label with percent:1 reads 33,4 %. percent expects a fraction (0.334), as everywhere else.

Some tips:

Missing and null values

Value Bar Line / area Pie / donut Scatter
null or missing key No bar (the slot stays empty) A gap: the line stops and starts again at the next value Slice left out Point left out
0 A zero-height bar A point on the zero line Slice left out A point at 0
Negative A bar below the zero line A point below zero Slice left out A point
Text (non-numeric) Treated as missing, with a validation warning Same Same Same

A gap is usually what you want for months that haven't happened yet or a store that opened mid-year. To draw a zero instead, send 0. In examples/sales-dashboard, the Lappi region opened in April: its January–March values are null, so its line starts in April.

When data is missing, null or an empty array (or seriesFrom is empty), emptyText is drawn in the middle of the box. Use visibleIf on the chart instead if it should disappear completely.

Charts, anchors and pagination

Pagination and anchors

The body area of each page is the page height minus the top and bottom margins, the header height and the footer height.

{ "id": "notes", "type": "text", "content": "{{notes}}", "overflow": "grow", "x": 40, "y": 0, "width": 515, "height": 14,
  "anchors": { "top": { "targetId": "items", "edge": "bottom", "offset": 12 } } }

anchors is keyed by the edge of this element (top, bottom, left or right). The value says which edge of which element (targetId) it attaches to, plus an offset in points. When an anchor sets top, the element's own y is ignored. targetId: "page" attaches to the page edges. Chains work: the invoice example anchors VAT under the table, a rule under VAT, the total under the rule, and the notes under the total.

To force a new page, use a pageBreak element.

Repeating elements

Header and footer bands repeat on every page, and a table repeats its header row. To repeat any other body element (a KPI strip under the header, a "Confidential" stamp, a running summary, a side note) set repeat on it:

{ "id": "kpis", "type": "group", "repeat": "all", "x": 30, "y": 84, "width": "100%", "height": 40, "children": [
  { "id": "kpiBox", "type": "rect", "x": 0, "y": 0, "width": "100%", "height": 40, "fill": "#f1f5f9", "radius": 4 },
  { "id": "kpiTotalLabel", "type": "text", "style": "kpiLabel", "content": "MYYNTI YHTEENSÄ", "x": 12, "y": 6, "width": 180, "height": 10 },
  { "id": "kpiTotal", "type": "text", "style": "kpiValue", "content": "{{report.summary.total | currency:\"EUR\"}}", "x": 12, "y": 17, "width": 180, "height": 18 }
] }
repeat Drawn on
"none", false or omitted The page it is laid out on only (the default)
"all", true Every page of the document, including pages before the one it is laid out on and the pages after a pageBreak
"following" Every page after the one it is laid out on: continuation pages only, e.g. a compact "continued" strip

Laid out once, drawn on other pages

A repeated element is laid out once, like any other element: its x/y, its anchors, visibleIf, overflow: "grow" and auto sizes are worked out on its home page (the page it lands on, usually page 1). The engine then draws the same box at the same position on every other page in its range. It is not laid out again per page, so it has the same size everywhere, and a hidden (visibleIf false) repeated element is hidden on every page.

Repeated elements are drawn on each page before that page's flowing content, so tables and anchored elements on the page sit on top of them, as on the home page.

Reserved space

On every page where an element is drawn as a repeat (every page in its range except its home page), the flowing content gives it room, so a table never runs underneath the strip:

"Content" here is everything that uses the body area page by page: a table's continuation segments, elements that move to the next page because they don't fit, and elements anchored to page top or bottom. If a reservation would leave less than 20% of the body height, the engine warns and ignores that element's reservation (it is still drawn).

Tables under a repeated strip

This is the main use. In examples/sales-report the KPI strip is a group with repeat: "all" at y: 84, just under the 50 pt header. On page 1 the charts and the table are placed under it as usual. On pages 2 and later the table's header row (with repeatHeader) starts at the strip's bottom (84 + 40) plus repeatGap, instead of at the top of the body area, and the page break check uses that page's own bottom (raised by any repeated element in the lower half). Rows are still never split.

A repeated element near the bottom, such as a summary bar above the footer, works the same way from below: the table breaks to the next page above it.

Page numbers in a repeated element

Bindings are evaluated once, except {{page}} and {{pages}}, which are evaluated per page, as in the header and footer. A repeated text such as "Sivu {{page}} / {{pages}}" shows the right number on every page. Charts in a repeated element compute their data once and draw the same chart on each page.

Repeating several elements: group them

repeat belongs on top-level body elements. To repeat a block made of several elements, put them in a group and set repeat on the group. The children's x/y become relative to the group, so subtract the group's position: a text at x: 42, y: 90 inside a group at x: 30, y: 84 becomes x: 12, y: 6, and a "100%" width now means the group's width. The designer does this in one step: select the elements, then Group & repeat on every page.

Setting repeat on several sibling elements also works; grouping keeps them together and gives other elements one id to anchor to.

Limits and validation

Case Result
repeat on a table Error. Tables flow across pages; use repeatHeader to repeat the header row. Only "none"/false is accepted.
An unknown value ("every", "All", 1) Error.
A repeated element anchored to a non-repeated element (any side) Error: repeated elements may only anchor to the page or to other repeated elements, because they are laid out before the rest.
A non-repeated element anchored to a repeated one Allowed. It uses the repeated element's box on its home page, e.g. anchor the first chart under the KPI strip.
repeat on a header/footer band element, a group child or a pageBreak Ignored, with a warning. Band elements already repeat; set repeat on the group instead of its children.
Reservation leaves less than 20% of the body height Warning; that element's reservation is ignored.

With no repeated elements, layout and output are exactly as before. Each repeat adds only its draw calls on each page.

PDF standards and metadata

The optional pdf object turns on archival and accessible output and sets the document properties:

"pdf": {
  "conformance": "PDF/A-3b",
  "ua": true,
  "metadata": { "title": "Invoice {{invoice.number}}", "author": "{{seller.name}}", "created": "{{invoice.date}}" },
  "attachments": [{ "name": "invoice-data.json", "src": "data.json", "mimeType": "application/json", "relationship": "Source" }]
}

The full reference, covering what gets tagged how, validation with veraPDF, and the limits, is in pdf-standards.md.

Form fields, signatures and encryption

Element type field adds interactive AcroForm fields (text, checkbox, radio, dropdown, signature) whose default values come from bindings. liuska render|batch|serve flags apply digital signatures (PAdES) and AES-256 encryption; the template never does. See forms-and-signing.md and examples/order-form.

Sample data

"sampleData": { ... } (inline) or "sampleDataFile": "sales.sample.json" (relative path) supplies data for the designer's live preview. liuska render without -d also uses it, so a template plus its sample data is a complete, reproducible example. In the designer, data you paste or load stays in the browser unless you choose Embed in template, and sampleDataFile is loaded through liuska serve relative to its --templates directory. See designer.md.

Pre-v1 templates

The original proof-of-concept format (files without "version") is no longer supported: Liuska and the designer reject such files with an error. To convert one by hand:

Pre-v1 v1
pageSize: "A4" page.size
orientation: "Portrait" / "Landscape" page.orientation: "portrait" / "landscape"
margins page.margins
table variable: "myTable" with [[header…], [row…]] data + autoColumns (header from row 0)
text variable: "key" content: "{{key}}"
type: "snippet" + snippetPath group + snippetPath
rect without fill (was grey) "fill": "#c8c8c8"
text without fontSize (was 12pt) "fontSize": 12, or a defaultStyle
table sampleData / sampleDataFile template-level sampleData / sampleDataFile
table scalingHeight, keepAspectRatio removed; use scalingWidth

Add "version": 1 at the top. anchors, children and scalingWidth are unchanged.