HTML¶
Pressjet prints HTML with the same engine as JSON documents. The HTML and its print CSS are compiled into the native document format, then laid out, paginated and written like any document: same speed, same fonts, same layout report, same PDF/A and PDF/UA.
pressjet render lease.html -o lease.pdf # images and font files beside it are read
pressjet check lease.html # the compiler's findings, then the layout report
pressjet compile lease.html > lease.json # the native document, to keep as a template
Over HTTP, POST /v1/html takes { "version": 1, "html": "…" } with optional stylesheets,
images (names mapped to base64), omitImages, fontFamily (the default family), fonts,
profile (pdf-ua-1, pdf-ua-2, pdf-a-2b, pdf-a-3b, pdf-a-4, pdf-a-4f),
conformance, created and lang. For accessible PDF 2.0 archival output, send
"conformance":["pdf-ua-2","pdf-a-4"] with a document title, a language and a creation date. POST /v1/check takes the
same body and answers with every finding at once. Nothing is fetched from the network.
Binary images¶
Use multipart/form-data on POST /v1/html to send JPEG or PNG files as binary
parts. Put the JSON request in the text field request. Use each image's exact
src as its file field name. A field name can be a relative path such as
photos/kitchen.jpg. Its segments may contain letters, digits, dots, hyphens
and underscores. An attachment name must be unique, including names in images.
curl --fail-with-body http://localhost:8080/v1/html \
-H "Authorization: Bearer $PRESSJET_API_KEY" \
--form-string 'request={"version":1,"html":"<img src=\"photos/kitchen.jpg\" alt=\"Kitchen\">"}' \
-F 'photos/kitchen.jpg=@kitchen.jpg;type=image/jpeg' \
-o report.pdf
Multipart uses the native engine and accepts up to 64 files. The full body follows
PRESSJET_MAX_REQUEST_BYTES (20 MiB by default). The manifest and the JSON-only
HTML input each have a separate 4 MiB ceiling. Binary photos count toward
PRESSJET_MAX_PIXELS just like inline images. For example, 24 images of 2000 by
1500 pixels need a budget of at least 72 million pixels. When that load is
expected, size the worker memory and set PRESSJET_MAX_PIXELS accordingly.
The server admits up to one in-flight binary upload or render per worker.
What the compiler reads¶
- The cascade. Browser defaults (margins of paragraphs and headings, list indents, bold
headings,
body { margin: 8px }),<style>elements,stylesheets,styleattributes, specificity,!important, inheritance,inherit. Selectors: type, class, id, attribute, descendant, child,:first-child,:last-child,:only-child,:first-of-type,:last-of-typeand:nth-*(an+b). - Boxes. Block flow with collapsing margins, inline formatting with nested spans,
<br>, white-space collapsing,display: flexwith its properties,display: gridwith explicitgrid-template-columns(fr, lengths, percentages,repeat()) andgap,position(absolute;fixedrepeats on every page), widths, heights,box-sizing, margins, padding, borders on each side, radius, background colour, opacity,visibility,transform. - Text. Font family lists, sizes (keywords,
em,rem,%), weights,italic,text-decoration,text-transform,letter-spacing,line-height,text-align: justify,orphans,widows,white-space: pre. - Lists. Markers drawn outside as browsers draw them (disc, circle, square as shapes; decimal,
roman and alphabetic numbers as text),
startandvalue,list-style-position: inside. - Tables. Rows as rows, cells centred in their row (
vertical-align),<thead>rows repeated on every page, columns sharing the width in proportion to their longest content or their stated width,colspan, collapsed borders drawn once or cells spaced byborder-spacing. - Pages.
@pagesize (named,landscape, or two lengths) and margins; margin boxes (@top-left…@bottom-right) with strings andcounter(page)andcounter(pages); running elements (position: running(name)placed bycontent: element(name));::beforeand::aftercontent with strings,attr()and the page counters;break-before,break-afterandbreak-inside(and thepage-break-*names);@media print. - Fonts and images.
@font-facewith an embeddeddata:URL or an attached file; images as attachments ordata:URLs, in blocks or in a line of text. Inline SVG shapes and paths render as raster images in the PDF. Usearia-labelor an SVGtitlefor an informative graphic, oraria-hidden="true"for decoration. Convert SVG text to paths before rendering. - Structure. Headings, paragraphs, lists, tables, header cells, sections, captions and image
alternatives carry their roles, so
profile: "pdf-ua-1"writes a tagged PDF from ordinary semantic HTML.
What it cannot honour (box-shadow, unsupported selectors such as :not(), scripts) is
reported as ignored_css or ignored_html and left out, as a browser ignores what it does not
know. Two things stop a document: an image that is not attached (missing_resource) and a font
family that is not available with no generic family after it (font_substituted). A family that
is not available but has a fallback is reported and the fallback is used.
An absolute box with a fixed-length first-page top inset can resolve against the initial containing block through ordinary static block ancestors. Its placement on the page and its original position in the pagination flow are tracked separately. Positioned ancestors, transforms and unresolved insets keep the existing local positioning behavior.
A fixed block with an explicit width can place one float: right block alongside a
preceding inline image. This covers repeating print headers with a logo and a title.
Floats elsewhere are reported as ignored_css.
Text in inline <a> elements can link to an HTTP(S) URL or a named destination in the PDF.
For repeated HTML IDs, the first occurrence is the destination and CSS still sees all IDs.
PDF/UA output keeps the link text and appearance without interactive annotations.
How close it is to Chrome¶
A synthetic lease set (a notice, an addendum and three leases of 10 to 47 pages, in bench/leases) is rendered from its print HTML and compared with Gotenberg (Chromium) by poppler: same text word for word, same page count, and every page starting at the same word, in all five documents. Over HTTP (median of 7 requests), the 20-page lease took 53.22 ms from the same HTML against 284.11 ms in Gotenberg, and the 47-page lease 116.16 ms against 405.55 ms, with a peak of 22.44 MiB against 569.25 MiB.
For automatic table columns, Pressjet estimates a shared width from text and declared inline image widths or width limits. Chromium measures intrinsic content, so column widths and table page breaks can differ. Text wrapping around floats remains unsupported.
Inline images with baseline alignment reserve space below the line according to the containing font and line height. This covers the line spacing of thumbnails next to text. Mixed-font baselines, short images, and other vertical alignment modes can still produce different line geometry.
In quirks mode, Pressjet drops adjoining browser-default top margins at the start of the body, as Chromium does. Author-supplied top margins and padding still apply.
The reference engine¶
A deployment can also run the optional WeasyPrint service (self-hosting) and
ask for it with "engine": "reference", to compare. It accepts a stricter profile and is slower;
its refusals list every element, property and font it refused. The x-pressjet-engine response
header says which engine printed a PDF.
Factur-X and ZUGFeRD invoices¶
Send facturX as the UTF-8 CrossIndustryInvoice XML string with pdf-a-3b and a
creation date. PressJet embeds the XML as factur-x.xml, sets its relationship and writes
the XMP schema from the guideline ID. The supported profiles are MINIMUM, BASIC WL, BASIC,
EN 16931 and EXTENDED. Add pdf-ua-1 to generate an accessible carrier document.
Validate invoice business rules and agreement between the XML and the visible PDF in your
billing workflow. The engine checks XML structure and the guideline ID.
import { readFile } from "node:fs/promises";
import { Pressjet } from "pressjet";
const client = new Pressjet({ apiKey: process.env.PRESSJET_API_KEY });
const pdf = await client.html(await readFile("invoice.html", "utf8"), {
conformance: ["pdf-a-3b", "pdf-ua-1"],
created: "2026-11-30T15:30:00Z",
facturX: await readFile("invoice.xml", "utf8"),
});