Guide

Options and frontmatter

PdfRendererOptions, pdf frontmatter keys, merge order, and page chrome.

renderPdf(), createPdfRenderer(), and the Node helpers accept PdfRendererOptions:

OptionTypeDescription
pdfPdfPageConfigPage size, margins, typography, metadata. String header / footer compile into chrome.
chromePdfChromePage header, footer, and watermark elements. Replaces compiled string templates.
visualsPdfVisualsPrint faces and table / quote / image map
pluginsComarkPlugin[]Parser plugins (math, mermaid, binding, …)
componentsRecord<string, JasyComponentFn>Custom jasy component factories by tag name
fontsRecord<string, Uint8Array | FontFaces>Font paths or bytes; registered with addFont
dataRecord<string, unknown>Binding data for {{ }}, :attr, ::if, ::for
eachRecord<string, unknown>[]Render the body once per entry, with a page break between entries. Each entry is merged over data.

Also accepts Comark ParserOptions (autoClose, registerDefaultPlugins, …). Autolinks come from the default linkify plugin.

Merge order

Last write wins: frontmatter.pdf → options.pdf.

pdf / frontmatter

Set defaults in code via options.pdf, or per document under a pdf: frontmatter block (same keys):

---
pdf:
  format: A4          # page size (A4, Letter, A3, A5, …); ignored when width + height are set
  width: 50mm         # custom page width (pair with height)
  height: 65mm        # custom page height (pair with width)
  orientation: portrait  # portrait | landscape
  margin: 20mm        # length string, points number, or { top, right, bottom, left }
  gap: 10             # space between block children (points)
  justify: start      # page main-axis alignment
  align: start        # page cross-axis alignment
  font: Helvetica     # document default font
  fontSize: 11        # document default text size (points)
  color: "#1b2433"    # document default text color
  lineHeight: 1.5     # document default line-height
  textAlign: left     # document default text align
  title: "My Report"  # PDF metadata + accessibility title
  author: "Acme"
  lang: en-US
  accessible: false
  onOverflow: error   # error | warn | ignore
  header: "My Report" # compiles to chrome.header; tokens: {{ page }}, {{ totalPages }}
  headerLeft: "Draft"
  headerRight: "Confidential"
  footer: "Page {{ page }} of {{ totalPages }}"
  footerLeft: "Company Name"
  footerRight: "2026"
---

margin is the paper inset only. Header and footer sit inside that box and take their own height. Do not add chrome height into margin. Pass chrome.header / chrome.footer to replace the compiled strings. Pass chrome.watermark as a Positioned overlay; it is not part of the header band.

Length values accept mm, cm, in, pt, px, or a bare number (treated as points).

const bytes = await renderPdf(markdown, {
  pdf: {
    format: 'Letter',
    margin: '25mm',
    footer: 'Page {{ page }} of {{ totalPages }}',
  },
})
Header and footer strings support {{ page }} and {{ totalPages }} tokens. Pass chrome.header / chrome.footer to replace the compiled strings with jasy elements.
Copyright © 2026