Native binary
The engine as a single Linux executable: one command reads an HTML file and writes a PDF or an image. It is the fastest way to render on your servers, with nothing else to install.
Install
Download the Linux binary from your dashboard and unpack it where your service runs:
tar xf palatine-native-linux-x64-*.tar.gz
./palatine --help | File | Purpose |
|---|---|
palatine | The executable. |
README.txt | The system requirements measured on this build: C library versions and system libraries. |
build-info.json | Version, commit and build date. |
LICENSE, third-party/ | Notices for the engine and the libraries it includes. |
The binary targets Linux on x86-64 with glibc. Alpine (musl) and older distributions are not qualified: check README.txt against your system. It reads no system font and needs no browser. On macOS, Windows or
ARM, use the WebAssembly build, which your license also covers.
Usage
./palatine --license palatine-license.txt \
--input report.html \
--font Body.ttf --font-family Body \
--paginate --format pdf --width 794 --height 1123 \
--output report.pdf --input, --font, --format and --output are required. On
success the command prints Rendered … bytes to report.pdf and exits with status 0.
The license comes from --license, or from the PALATINE_LICENSE environment variable,
which holds either the path of the license file or the token itself:
export PALATINE_LICENSE=/etc/palatine/palatine-license.txt
./palatine --input report.html --font Body.ttf --format pdf --output report.pdf Size
--width and --height are CSS pixels and default to 800 × 600. The command line has no
automatic height: without --paginate, the output is exactly one page or image of that size, and
content below it is cut. With --paginate, a PDF gets as many pages as it needs, and @page rules in the document set the paper size and margins. See pagination.
From your application
Run the binary as a child process. Write the HTML to a temporary file, then read the output file.
import { execFile } from "node:child_process";
import { promisify } from "node:util";
const run = promisify(execFile);
export async function renderPdf(input: string, output: string) {
try {
await run("/opt/palatine/palatine", [
"--input", input,
"--font", "/opt/palatine/fonts/Body.ttf", "--font-family", "Body",
"--paginate", "--format", "pdf", "--width", "794", "--height", "1123",
"--output", output,
], { env: { ...process.env, PALATINE_LICENSE: "/etc/palatine/palatine-license.txt" } });
} catch (error) {
// Exit status 1: the first line of stderr says why.
const { stderr } = error as { stderr?: string };
throw new Error("Palatine failed: " + (stderr ?? String(error)).split("\n")[0]);
}
} Or from a shell script, for a batch:
for file in invoices/*.html; do
./palatine --input "$file" --font Body.ttf --font-family Body \
--paginate --format pdf --width 794 --height 1123 \
--output "pdf/$(basename "$file" .html).pdf" || echo "failed: $file" >&2
doneFonts and resources
--font loads the document's main font under the name given by --font-family (NativeFont when omitted). It is also the fallback for any family the document names without
providing it.
The binary never opens the network, and reads only the files you name. Every other resource is mapped with a
repeatable URL=path flag, where the URL is written exactly as in the document:
./palatine --input letter.html \
--font fonts/Body.ttf --font-family Body \
--image assets/logo.png=assets/logo.png \
--image https://example.com/photo.jpg=cache/photo.jpg \
--stylesheet theme.css=theme.css \
--font-resource fonts/Display.ttf=fonts/Display.ttf \
--format pdf --output letter.pdf | Flag | Answers |
|---|---|
--font-resource | A font file named by @font-face { src: url(…) }, for more families, weights and styles. |
--stylesheet | A stylesheet named by <link rel="stylesheet"> or @import. |
--image | An image named by <img> or a CSS url(…). |
A resource that is not mapped is skipped without an error, so look at the output when you add one. data: URLs and <style> blocks need no flag: a self-contained HTML file is the
simplest input.
Flags
| Flag | Description |
|---|---|
--input file.html | Required. The document. |
--output file | Required. Where to write the result. |
--format pdf|png|webp|svg | Required. The output format. |
--font file, --font-family name | Required font, and the family name it gets. |
--width px, --height px | Layout size. Default 800 × 600. |
--license file|token | The license. Default: $PALATINE_LICENSE. |
--paginate | Paged PDF, like options.pagination. |
--knuth-plass | Knuth–Plass justification, like typography.justification.algorithm. |
--optical-margins | Hanging punctuation. Needs --knuth-plass. |
--space-min, --space-normal, --space-max | Word-spacing factors. Need --knuth-plass. |
--last-line-min, --last-line-penalty | Last-line quality. Need --knuth-plass. |
--hyphen-min-word, --hyphen-min-before, --hyphen-min-after | Hyphenation minima. |
--hyphen-penalty, --hyphen-consecutive-penalty, --hyphen-max-consecutive | Hyphenation controls. |
--glyph-scale factor | Horizontal glyph scale, 0.98 to 1.02. |
--linked-footnotes | Like options.linkedFootnotes. |
--pdf-title text, --pdf-language tag | PDF metadata. |
--pdf-ua | Strict PDF/UA-1. |
--pdf-x variant | PDF/X print file: PDF/X-1a:2001, PDF/X-3:2002 or PDF/X-4. Not with --pdf-ua. |
--pdf-x-output-condition name, --pdf-x-output-profile file | Printing condition of a PDF/X file and its CMYK ICC profile. Default condition CGATS TR 001. |
--base-url URL | Resolves relative link targets in the PDF. Nothing is fetched. |
--image, --stylesheet, --font-resource | URL=path resources, repeatable. |
--warnings-json file | Writes the render's warnings as JSON. |
--max-memory size | Memory ceiling, for instance 256MiB. A document that cannot fit fails. |
--stream | Writes a paginated PDF to the output as pages are made, instead of holding it in memory. |
--help | Prints the usage. |
The flags mirror the rendering options, where each one is explained.
Exit status and warnings
- Status 0: the output file is written.
- Status 1: nothing usable is written. The first line of the error output says why: an unreadable file, an invalid flag, a license problem, a memory ceiling, a strict PDF/UA refusal or a PDF/X refusal.
- Warnings do not change the status. Each one is printed on the error output as
warning <code>: <message>, and--warnings-jsonsaves them as a list, empty when there are none:
[
{
"code": "pagination.monolithic-overflow",
"message": "Unbreakable content taller than the page area is sliced at the page edge",
"source": "img"
}
] The codes are the same on every target: see warnings.