Document format¶
A Pressjet document is JSON: a tree of nodes, each { "type", "properties", "children" }. The
SDKs build it for you; this page describes what they build. The authoritative definition is
spec/document.schema.json.
{
"type": "document",
"properties": { "title": "Report" },
"children": [
{
"type": "page",
"properties": { "size": "A4", "style": { "padding": 40, "fontFamily": "Helvetica" } },
"children": [
{ "type": "text", "properties": { "style": { "fontSize": 24 } }, "children": ["Report"] },
{ "type": "view", "properties": { "style": { "flexDirection": "row", "gap": 12 } }, "children": [] }
]
}
]
}
Every object is closed: an unknown node type, property or style is refused with a message that
names it and its place (invalid_document, see errors). Nothing is guessed.
Nodes¶
| Node | Properties | Children |
|---|---|---|
document |
title, author, lang, created, conformance, verification |
one or more page |
page |
size, style |
view, text, image, barcode, table |
view |
style, fixed, hideOnFirstPage, wrap, break, keepTogether, keepWithNext, role, level, alt, id |
view, text, image, barcode, table |
text |
style, fixed, hideOnFirstPage, wrap, break, keepTogether, keepWithNext, pageNumberText, role, level, alt, id |
strings, text, image |
image |
src (required), style, fixed, hideOnFirstPage, wrap, break, keepWithNext, role, alt, id |
none |
barcode |
format and value (required), errorCorrection, columns, style, fixed, hideOnFirstPage, wrap, break, keepWithNext, role, alt, id |
none |
table |
columns (required), rows, style, headerStyle, rowStyle, repeatHeader, keepWithNext, break, id |
none |
pageis a template, not a single sheet: its content flows onto as many pages of the same size and style as it needs.sizeisLETTER(default, 612 × 792 pt),A4,LEGALorA5, optionally followed bylandscape, or a width and a height ("210mm 297mm").textchildren are strings, or nestedtextnodes that act as spans with their own style (bold words in a sentence). Text inheritscolor,fontFamily,fontSize,fontWeight,letterSpacing,lineHeight,textAlignandopacityfrom its ancestors. Animageinside atextnode is accepted and checked, but not drawn yet; put images in aview.imagesrcis PNG or JPEG bytes as base64, or adata:URL. Images are never fetched from the network. JPEG camera orientation is honored.barcodedraws a QR, PDF417, Data Matrix or Code 128 symbol as vectors;valuemay hold{pageNumber}and{totalPages}. The document propertyverificationstamps every page with a code that names the document, its source and the page. See Barcodes and verification codes.tablebuilds a table fromcolumnsandrows. A column is a header string or{ header, width, align, style }; a column without a width takes an equal share of the rest. A row is a list of one cell per column: a string, a number,nullor a node. The table becomes a view with roletable: a header row withfixed: truethat repeats on every page the table reaches (repeatHeader: falseprints it once), and a row view withwrap: falseper row, so no row is split.headerStyleandrowStyleare written over the defaults (bold header with a 1 pt rule; rows with 2 pt vertical padding and a 0.5 pt#ddddddrule).hideOnFirstPageon a node withfixed: trueleaves it off the first page it would repeat on: a running header that starts on page 2.
Pagination¶
fixed: truerepeats a node on every page its parent spans: headers, footers, watermarks. Usually combined withposition: "absolute".wrap: falsekeeps a node whole: if it does not fit in the rest of the page, it moves to the next. Images never split.keepTogether: trueon a wrapping view moves it as a group when it fits on a fresh page. A taller group paginates through its children. Use it on a signature section and setwrap: falseon each signer to keep the writing area with its label.keepWithNext: trueforbids a page break between the node and the start of the next one (its firstorphanslines, or its first row), as CSSbreak-after: avoid: put it on headings. Chains of them move together. A forcedbreakwins, and a chain taller than a page is cut.orphansandwidows(styles, inherited, 2 by default) are the fewest lines of a paragraph left at the foot of a page and carried to the next.break: truestarts the node on a new page, also inside a container that fits.- A margin that meets a page break is dropped on the next page (unless a
breakforced it) and never pushes a node that fits onto the next page, as in CSS. pageNumberTexton atextnode replaces its children with the template, filling in{pageNumber}and{totalPages}:"Page {pageNumber} of {totalPages}".- A row whose cells would be torn apart by a page break moves whole to the next page when it fits there.
Signature fields and draft copies¶
Use an empty view for the writing area, followed by the signer's name. Apply the border only to the writing area. These styles use points and reserve space for handwriting.
| Appearance | Writing area style |
|---|---|
| Line | {"width":240,"height":52,"borderBottomWidth":0.75} |
| Framed box | {"width":240,"height":52,"borderWidth":0.75} |
| Square | {"width":84,"height":84,"borderWidth":0.75} |
For a draft, place a fixed, absolutely positioned text or image first among the page's children so the body paints over it. The Python example offers a horizontal text watermark and an embedded transparent PNG for the diagonal version. Both repeat on every sheet generated from that page template.
Styles¶
Styles use CSS names in camelCase, applied in the order written (a longhand after a shorthand overrides it).
Layout. A view is a flex container, column by default; display: "block" makes it CSS
block flow instead, where children fill the width and adjoining vertical margins collapse into
the larger (what an HTML document expects). For flexbox:
flexDirection (column, row, column-reverse, row-reverse), flexWrap (nowrap, wrap,
wrap-reverse), justifyContent (flex-start, flex-end, center, space-between,
space-around, space-evenly), alignItems and alignSelf (flex-start, flex-end, center,
stretch, baseline), flex (1 means grow 1, shrink 1, basis 0; also auto, none,
initial, or "grow shrink basis"), gap (row, then optional column).
Box. width, height, minWidth, minHeight, maxWidth, maxHeight, padding*,
margin* (padding: "8 16" follows CSS: top/bottom then left/right; paddingVertical,
paddingHorizontal, marginVertical and marginHorizontal too), boxSizing (border-box, the
default, or content-box), position (relative, absolute) with top, right, bottom,
left. transform (rotate(), scale(), translate(), skew()) and transformOrigin change
only how a node is painted, as in CSS: a fixed, absolute, semi-transparent text rotated -35deg
is a draft watermark on every page.
Borders and background. borderWidth, borderColor, borderStyle (solid, dashed,
dotted, none), or the shorthand borderWidth: "1 solid #ddd"; each side on its own with
borderTop, borderRight, borderBottom, borderLeft (the same shorthand) or their Width,
Color and Style longhands; borderRadius and the four corner properties such as
borderTopLeftRadius; backgroundColor; opacity (0–1). A side
without a border paints nothing.
Text. fontFamily, fontSize, fontWeight (100–900 or normal, bold, semibold …),
fontStyle (normal, italic), textDecoration (underline, line-through), color,
letterSpacing, lineHeight (a bare number or a percentage is a multiple of the font size and is
inherited as a multiple, as in CSS; a length such as 14pt is absolute; the extra height is
shared above and below the glyphs), textAlign (left, right, center, justify),
orphans, widows.
Images. objectFit (fill, contain, cover, none, scale-down), objectPosition
("left top", "center", lengths). The image property inlineBaseline reserves
the space below the parent font's baseline for an image in a bottom-aligned row.
Units. Numbers are points (1/72 inch). Strings may use pt, in, mm, cm, px, rem
(18 pt), vw and vh (of the page), % (of the parent) and auto where it makes sense.
Colors. Any CSS color: #rgb, #rrggbb, #rrggbbaa, names, rgb(), rgba(), hsl().
Fonts¶
fontFamily |
Faces embedded in the engine |
|---|---|
Helvetica (default, also sans-serif) |
Liberation Sans regular, bold, italic, bold italic |
Times-Roman (also serif) |
Liberation Serif regular, bold, italic, bold italic |
Courier (also monospace) |
Liberation Mono regular, bold, italic, bold italic |
Archivo |
Archivo 400, 600 and 700, upright and italic |
fontFamily may be a CSS list, "Brand, Archivo, sans-serif": the first family the document has
wins. A face is chosen as CSS chooses it: the style, then the closest weight by the CSS rule. A
family without an italic is slanted; a weight or style the family lacks is reported by the layout
report as font_substituted.
Your own fonts, in two ways:
- Per server: every
.ttfand.otfin the folderPRESSJET_FONTS_DIRnames is installed at startup (the server, its workers and the CLI);/v1/infolists the families. - Per request:
fonts: [{ "family": "Brand", "weight": 700, "style": "normal", "src": "<base64>" }]besidelayout(family, weight and style default to what the file says). Faces are cached by digest, so a font sent with every request is read once. The CLI also accepts a file path assrc.
Fonts whose license forbids embedding are refused. The Liberation faces have the metrics of the PDF standard fonts. Text covers Latin, Greek and Cyrillic; characters a face lacks fall back to Liberation Sans of the same weight and style, and then to DejaVu Sans for arrows, mathematical and technical symbols, check marks and box drawing. Characters no face has are reported by the layout report. CJK, right-to-left scripts and emoji are on the roadmap.
Structure, standards and anchors¶
roleplaces a node in the logical structure of a tagged PDF:heading(withlevel1–6),paragraph,list,listItem,label,listBody,table,tableHead,tableBody,row,headerCell,cell,figure,caption,section,quote, orartifactfor decoration. A text without a role is a paragraph, an image a figure (withalt), and a view without a role is transparent. AlistItem's content outside itslabelandlistBodyis tagged as its body, a run of other content in alistbecomes one item, and alistItem,labelorlistBodyoutside alistis placed in one. Headings also become the PDF's bookmarks, tagged or not.conformanceon the document asks forpdf-a-2b(archiving: embedded output intent, XMP and identification),pdf-ua-1(accessibility: a tag tree in reading order, with repeated headers, footers and watermarks as artifacts) or both. PDF/UA needstitleandlang, PDF/A needscreated(the engine reads no clock; the CLI fills in today). A part of a paragraph or table on each page stays one element. The layout report lists what is missing before rendering. Merged PDFs carry no conformance claim.pdf-ua-2opts into the PDF 2.0 accessibility profile. It requires a title, language and alternative text for figures. Bookmarks and internal links target tagged headings. Useidon a heading to name the destination. Combine it withpdf-a-4for archival output, orpdf-a-4fwhen attaching associated files. These profiles refuse interactive fields. Verify machine-checkable rules and review reading order with assistive technology before delivering a document.idnames a node: the layout report'sanchorssay on which page and where it was placed, and the PDF carries it as a named destination. Name a signature linesig:tenantto place a signature box there without hidden text markers.hrefon text makes its spans clickable in regular PDFs. It accepts an absolute HTTP(S) URL or#idfor a named destination. PDF/UA currently preserves the text without link annotations.
HTML¶
/v1/html, pressjet render page.html and pressjet compile page.html (which prints the
native document) read print HTML and CSS and compile it into this format, then render with the
same engine. See HTML for what the compiler reads.
Text layout¶
Lines break at Unicode line-break opportunities, first fit, without automatic hyphenation; a word
wider than its line breaks between characters. justify spreads the spaces of every line but the
last.
Limits¶
Each server sets its own limits (GET /v1/info reports them). The defaults: 200 pages, 20,000
nodes, nesting 32 deep, 24 million image pixels, 100,000 characters per string, numbers within
±100,000.
Coming from react-pdf¶
The node kinds, property names and style names are react-pdf's, so a react-pdf component tree maps one to one. Differences:
- Line breaking is first fit without hyphenation (react-pdf uses Knuth–Plass with English hyphenation), so a paragraph can break at different words.
- Rows stay whole across page breaks when they fit on the next page; react-pdf splits them.
- Standard fonts are embedded (with the same metrics), so PDFs are slightly larger and look the same everywhere.
Link,Svg,Canvas,Noteand form fields are not supported yet.- Rendering is deterministic: the same document gives the same bytes (no creation date is written
unless the document states
created).
Fillable fields¶
Place a field directly under a page. Use a unique name, a label, fixed width and height in
points, and a text or checkbox kind. Text values are single-line printable ASCII in the
current implementation. Checkboxes take a boolean. Text that exceeds the field width is clipped
in its initial appearance. readOnly and required set the reader's editing flags.
{
"type": "field",
"properties": {
"name": "applicant",
"label": "Applicant name",
"kind": "text",
"required": true,
"style": { "width": 180, "height": 22 }
},
"children": []
}
Use default PDF output with fields. Tagged or archival output and transformed field pages are rejected. Viewers render and save widget edits. Verify the supported viewer in your intake workflow.
Associated files¶
pdf-a-3b and pdf-a-4f take a created date and one to eight associatedFiles on the
document. Each entry has a plain name, a mediaType, a human-readable description, a
relationship of source, data or supplement, and a base64 payload. The decoded
files share a 2 MiB limit. The native HTML API also accepts associatedFiles when requested
with one of those profiles.