Skip to content

Elements ​

Elements are the building blocks of headers and footers. Each element has a type and type-specific properties.

Element Types Overview ​

TypeDescriptionPrimary Property
textStatic or dynamic textcontent
imageEmbedded image (SVG, PNG, JPG)src
dateFormatted date/timeformat
titleDocument titlefallback
page_numberCurrent page numberformat
total_pagesTotal page countformat
spacerFlexible or fixed spacewidth

Text Element ​

Display static text or dynamic content with placeholders.

json
{
  "type": "text",
  "content": "Page {page} of {pages}",
  "font_size": "9px",
  "font_weight": "bold",
  "font_style": "italic",
  "color": "#333"
}

Properties ​

PropertyTypeDescription
contentstringText content, supports placeholders
font_sizestringCSS font-size ("9px", "10pt")
font_weightstring | numberCSS font-weight ("bold", "normal", 600)
font_stylestringCSS font-style ("normal", "italic", "oblique")
colorstringCSS color ("#333", "gray", "rgb(100,100,100)")
stylestringAdditional inline CSS

Examples ​

json
// Simple text
{ "type": "text", "content": "Confidential" }

// With placeholder
{ "type": "text", "content": "Author: {author}" }

// Styled
{
  "type": "text",
  "content": "DRAFT",
  "font_size": "12px",
  "font_weight": "bold",
  "color": "red"
}

// Page numbers
{ "type": "text", "content": "Page {page} of {pages}" }

Image Element ​

Embed an image (SVG, PNG, or JPG). Images are converted to base64 data URIs.

json
{
  "type": "image",
  "src": "./logo.svg",
  "height": "12mm",
  "alt": "Company Logo"
}

Properties ​

PropertyTypeDescription
srcstringPath to image file (relative to Markdown file)
heightstringCSS height ("12mm", "20px")
widthstringCSS width (usually omit to preserve aspect ratio)
altstringAlt text for accessibility
stylestringAdditional inline CSS

Supported Formats ​

  • SVG — Recommended for logos, scales perfectly
  • PNG — Good for images with transparency
  • JPG/JPEG — Good for photos

Examples ​

json
// Basic logo
{ "type": "image", "src": "./logo.svg", "height": "15mm" }

// With alt text
{
  "type": "image",
  "src": "./images/company-logo.png",
  "height": "12mm",
  "alt": "Acme Corporation"
}

// Fixed width (height auto-scales)
{ "type": "image", "src": "./icon.svg", "width": "20mm" }

TIP

Keep images small for faster PDF generation. SVGs are ideal because they're typically small and scale perfectly at any size.

Date Element ​

Display a formatted date or time.

json
{
  "type": "date",
  "format": "MMMM d, yyyy",
  "font_size": "9px"
}

Properties ​

PropertyTypeDescription
formatstringdate-fns format pattern (default: "yyyy-MM-dd")
font_sizestringCSS font-size
colorstringCSS color
stylestringAdditional inline CSS

Common Formats ​

FormatExample Output
yyyy-MM-dd2025-06-14
MMMM d, yyyyJune 14, 2025
MM/dd/yyyy06/14/2025
dd.MM.yyyy14.06.2025
d MMMM yyyy14 June 2025
EEE, MMM dSat, Jun 14
HH:mm14:30
h:mm a2:30 PM

See Date Formatting for the full reference.

Examples ​

json
// ISO date (default)
{ "type": "date" }

// US format
{ "type": "date", "format": "MM/dd/yyyy" }

// Long format
{ "type": "date", "format": "MMMM d, yyyy" }

// Date and time
{ "type": "date", "format": "yyyy-MM-dd HH:mm" }

// Styled
{
  "type": "date",
  "format": "MMMM d, yyyy",
  "font_size": "8px",
  "color": "#666"
}

Title Element ​

Display the document title from front matter or the filename.

json
{
  "type": "title",
  "font_weight": "bold",
  "fallback": "Untitled Document"
}

Properties ​

PropertyTypeDescription
fallbackstringText to show if no title is found
font_sizestringCSS font-size
font_weightstring | numberCSS font-weight
font_stylestringCSS font-style
colorstringCSS color
stylestringAdditional inline CSS

Title Resolution ​

The title is resolved in this order:

  1. title field in YAML front matter
  2. First H1 heading in the document
  3. Filename (without extension)
  4. fallback value (if specified)

Examples ​

json
// Basic
{ "type": "title" }

// With fallback
{ "type": "title", "fallback": "Untitled" }

// Styled
{
  "type": "title",
  "font_weight": "bold",
  "font_style": "italic",
  "color": "#2c3e50"
}

Page Number Element ​

Display the current page number.

json
{
  "type": "page_number",
  "format": "Page {page}",
  "font_size": "9px"
}

Properties ​

PropertyTypeDescription
formatstringFormat string with {page} placeholder
font_sizestringCSS font-size
colorstringCSS color
stylestringAdditional inline CSS

Examples ​

json
// Just the number
{ "type": "page_number" }

// With prefix
{ "type": "page_number", "format": "Page {page}" }

// Styled
{
  "type": "page_number",
  "format": "- {page} -",
  "font_size": "8px",
  "color": "#999"
}

INFO

Page numbers are rendered by Chromium at print time, so they're always accurate.

Total Pages Element ​

Display the total number of pages.

json
{
  "type": "total_pages",
  "format": "{pages} pages"
}

Properties ​

PropertyTypeDescription
formatstringFormat string with {pages} placeholder
font_sizestringCSS font-size
colorstringCSS color
stylestringAdditional inline CSS

Examples ​

json
// Just the number
{ "type": "total_pages" }

// With text
{ "type": "total_pages", "format": "of {pages}" }

TIP

For "Page X of Y" format, use a text element instead:

json
{ "type": "text", "content": "Page {page} of {pages}" }

Spacer Element ​

Add flexible or fixed space between elements in a zone.

json
{ "type": "spacer" }

Properties ​

PropertyTypeDescription
widthstringFixed width ("10mm", "20px"). If omitted, uses flex: 1

Examples ​

json
// Flexible spacer (fills available space)
{ "type": "spacer" }

// Fixed width
{ "type": "spacer", "width": "15mm" }

Use Case: Push Elements Apart ​

json
{
  "header": {
    "left": [
      { "type": "image", "src": "./logo.svg", "height": "10mm" },
      { "type": "spacer" },
      { "type": "text", "content": "Division Name" }
    ]
  }
}

The spacer pushes "Division Name" to the right edge of the left zone.

Common Styling Properties ​

Most elements support these styling properties:

PropertyTypeDescription
font_sizestringCSS font-size
font_weightstring | numberCSS font-weight
font_stylestringCSS font-style
colorstringCSS color
stylestringAdditional inline CSS styles

The style property allows arbitrary CSS:

json
{
  "type": "text",
  "content": "Important",
  "style": "text-transform: uppercase; letter-spacing: 2px;"
}

Next Steps ​

Released under the MIT License.