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:

terminal
tar xf palatine-native-linux-x64-*.tar.gz
./palatine --help
FilePurpose
palatineThe executable.
README.txtThe system requirements measured on this build: C library versions and system libraries.
build-info.jsonVersion, 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

terminal
./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:

terminal
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.

render.ts
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:

terminal
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
done

Fonts 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:

terminal
./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
FlagAnswers
--font-resourceA font file named by @font-face { src: url(…) }, for more families, weights and styles.
--stylesheetA stylesheet named by <link rel="stylesheet"> or @import.
--imageAn 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

FlagDescription
--input file.htmlRequired. The document.
--output fileRequired. Where to write the result.
--format pdf|png|webp|svgRequired. The output format.
--font file, --font-family nameRequired font, and the family name it gets.
--width px, --height pxLayout size. Default 800 × 600.
--license file|tokenThe license. Default: $PALATINE_LICENSE.
--paginatePaged PDF, like options.pagination.
--knuth-plassKnuth–Plass justification, like typography.justification.algorithm.
--optical-marginsHanging punctuation. Needs --knuth-plass.
--space-min, --space-normal, --space-maxWord-spacing factors. Need --knuth-plass.
--last-line-min, --last-line-penaltyLast-line quality. Need --knuth-plass.
--hyphen-min-word, --hyphen-min-before, --hyphen-min-afterHyphenation minima.
--hyphen-penalty, --hyphen-consecutive-penalty, --hyphen-max-consecutiveHyphenation controls.
--glyph-scale factorHorizontal glyph scale, 0.98 to 1.02.
--linked-footnotesLike options.linkedFootnotes.
--pdf-title text, --pdf-language tagPDF metadata.
--pdf-uaStrict PDF/UA-1.
--pdf-x variantPDF/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 filePrinting condition of a PDF/X file and its CMYK ICC profile. Default condition CGATS TR 001.
--base-url URLResolves relative link targets in the PDF. Nothing is fetched.
--image, --stylesheet, --font-resourceURL=path resources, repeatable.
--warnings-json fileWrites the render's warnings as JSON.
--max-memory sizeMemory ceiling, for instance 256MiB. A document that cannot fit fails.
--streamWrites a paginated PDF to the output as pages are made, instead of holding it in memory.
--helpPrints 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-json saves them as a list, empty when there are none:
warnings.json
[
  {
    "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.