PDF standards, accessibility and metadata
The template's optional pdf object makes Liuska write archival PDF (PDF/A-2 or PDF/A-3), accessible PDF (PDF/UA-1, tagged PDF), document properties and embedded files. When the template has no pdf object, output is unchanged.
"pdf": {
"conformance": "PDF/A-3b",
"ua": true,
"lang": "en-US",
"metadata": {
"title": "Invoice {{invoice.number}}",
"author": "{{seller.name}}",
"subject": "Invoice {{invoice.number}} to {{customer.name}}",
"keywords": ["invoice", "{{invoice.number}}"],
"creator": "Billing system",
"created": "{{invoice.date}}"
},
"attachments": [
{ "name": "invoice-data.json", "src": "data.json", "mimeType": "application/json",
"relationship": "Source", "description": "The data this invoice was generated from" }
]
}
A complete example is examples/invoice-pdfa.
Fields
| Field | Description |
|---|---|
conformance |
PDF/A-2b, PDF/A-2u, PDF/A-2a, PDF/A-3b, PDF/A-3u, PDF/A-3a, or none (the default). The renderer also accepts pdfa-3b and 3b. |
ua |
true claims PDF/UA-1 (ISO 14289-1). Implies tagged. Can be combined with conformance. |
tagged |
true writes the structure tree without claiming any standard. Implied by ua and by PDF/A level a. |
lang |
Document language (BCP 47). Default: the template locale, then en-US. |
metadata |
Document properties. They are written to both the Info dictionary and XMP, and kept consistent as PDF/A requires. Every field is a template string with {{ }} bindings. |
attachments |
Embedded files. See Attachments. |
Metadata
| Field | Description |
|---|---|
title |
Default: the template name. When the output is tagged, viewers show it in the title bar instead of the file name (DisplayDocTitle). PDF/UA requires a title. |
author |
XMP dc:creator |
subject |
XMP dc:description |
keywords |
A string, or an array joined with ", " |
creator |
The creating application. Default liuska. The producer is always liuska. |
created |
"now", 2026-01-31, an RFC 3339 time such as 2026-01-31T12:00:00+02:00, or a binding that yields one of these (e.g. "{{invoice.date}}"). |
modified |
Same formats as created. Default: created. |
Dates and determinism. Liuska writes no creation date unless created is set, so the same input always produces byte-identical output. Use "now" to stamp the render time. This is a change from earlier versions, which always wrote the current time into CreationDate. The PDF/A file identifier (/ID) is a digest of the document's metadata and layout, so it is stable too.
PDF/A
With conformance set, Liuska does the following:
- Writes an XMP metadata stream with
pdfaid:partandpdfaid:conformance. Withua, it also writespdfuaid:part, plus the PDF/A extension schema that describes it. - Adds an sRGB OutputIntent. The ICC v2 profile is generated in code, so no third-party profile file is shipped.
- Writes a file identifier.
- Embeds every font, as it always does: subset TrueType with
ToUnicode, so levelsuandaare covered. - Drops characters the font has no glyph for, because PDF/A forbids references to
.notdef. A render warning names them. Use a font that covers your text, or the font fallback chain once it is available. - Converts CMYK JPEGs to RGB, because DeviceCMYK is not allowed with an sRGB OutputIntent.
- Keeps transparency:
opacityand PNG alpha are allowed in PDF/A-2 and PDF/A-3 when an OutputIntent is present.
Level a also tags the document, exactly as tagged does.
PDF/A-2 or PDF/A-3? They are the same apart from attachments. PDF/A-3 may embed any file, which is how ZUGFeRD and Factur-X carry their XML. PDF/A-2 does not allow embedded files, so validation reports an error and the renderer skips them.
Not compatible with PDF/A: encryption. A signature added after rendering is fine as long as it is an incremental update.
Tagged PDF and PDF/UA
The structure tree follows template order, which is also the reading order: body elements in the order they are laid out, page by page. Each element is tagged according to its type:
| Element | Tag |
|---|---|
text |
P, or the element's role (H1...H6, Caption, BlockQuote, Note, Code, Span) |
table |
Table > TR > TH (header row, Scope=Column) / TD. Body rows and the totals row use TD. One Table spans all pages. Header rows repeated on later pages are pagination artifacts. Empty cells are kept as empty TDs, so every row has the same number of cells. |
image |
Figure with alt. Without alt, the image is treated as decoration and becomes an artifact. Validation warns about this in PDF/UA mode. |
chart |
Figure. alt defaults to the chart's title, then to "Chart". Write a real description in alt when the chart carries information the text doesn't. |
group |
Transparent: each child is tagged on its own. With role: "Sect" or "Div" the children are grouped under that element. With role: "Figure" and alt the whole group becomes one figure, e.g. a logo drawn from shapes. |
rect, line |
Artifact (decoration) |
| Backgrounds, borders, fills of text boxes and table rows | Artifacts |
| Header and footer | Pagination artifacts (/Header, /Footer). Exception: on page 1, a header or footer element with an explicit role is tagged as real content, which is useful for a document title in the header. |
Repeated elements (repeat) |
Tagged where they are laid out. The copies drawn on other pages are pagination artifacts. |
Element fields:
{ "type": "text", "role": "H1", "content": "Monthly report" }
{ "type": "image", "src": "logo.png", "alt": "{{company.name}} logo" }
{ "type": "rect", "role": "artifact" }
alt is a template string. role accepts any case in the renderer, while the schema lists the canonical spelling. role: "artifact" on any element marks it as decoration.
For PDF/UA, the catalog also gets /Lang, /MarkInfo, DisplayDocTitle, /StructParents and /Tabs /S on every page. Validation (liuska validate) checks the following:
- error: a missing title, a
Figurerole withoutalt, an unknownrole; - warning: an image without
alt, a skipped heading level (H1→H3), no language.
Attachments
| Field | Description |
|---|---|
name |
File name shown in the viewer (required, unique, bindings allowed) |
src |
File path relative to the template, or a data: URI |
content |
Inline text (template string, written as UTF-8), used when src is not set |
mimeType |
e.g. text/xml. Default application/octet-stream. |
description |
Shown in the viewer's attachment panel |
relationship |
PDF/A-3 AFRelationship: Source, Data, Alternative, Supplement, Unspecified (default) |
Files are listed both in the catalog's /AF array and in the EmbeddedFiles name tree. When the PDF also has a modification date, each file's Params carries Size, an MD5 CheckSum and that ModDate. Attachments also work in plain PDF without conformance.
ZUGFeRD / Factur-X need an XML attachment, which is already possible (relationship: "Alternative"). They also need their own XMP extension schema (fx: namespace), which Liuska does not write yet. content with bindings does not escape XML special characters, so generate the XML yourself and use src.
Validating
The examples pass veraPDF (PDF/A-2b, 2a, 3b, 3u, 3a and PDF/UA-1):
docker run --rm -v "$PWD:/data" verapdf/cli --format text /data/out.pdf # PDF/A, flavour taken from the XMP
docker run --rm -v "$PWD:/data" verapdf/cli -f ua1 --format text /data/out.pdf # PDF/UA-1
LIUSKA_STD_OUT=<dir> go test -run PDFStdExamples ./renderer renders every example with each profile into <dir>.
Performance
None of this costs anything for templates without pdf: output and speed are unchanged. With PDF/A-3b + PDF/UA, a 1-page report takes about 0.13–0.16 ms instead of 0.10 ms. A 10,000-row table takes about 56 ms instead of 37 ms, since it gets about 90,000 structure elements, one object each.
Limits
- Text is tagged per element. Multi-line text is one
P, and lines are not separated by spaces in the content stream (viewers infer the line breaks from position). - There is no
BBoxlayout attribute on figures, noLinkorAnnottags (Liuska has no links yet), and noLangper element. - Form fields and signature widgets: once they exist, PDF/UA needs them tagged as
Formwith aTUtooltip. Pages already have/Tabs /S. - PDF/A-1 is not supported. Use PDF/A-2b, which every current validator and archive accepts.