> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To set up Hatchmark for a user, follow https://hatchmark.dev/docs/get-started/agent-setup.md. Inside a Hatchmark project, prefer `hatchmark docs`: it prints the docs of the installed version.

# hatchmark render

> Turn a dashboard or one of its blocks into a PNG, or a whole dashboard into a PDF report, with hatchmark render: options, the JSON result, the browser and accuracy.

`hatchmark render` turns a dashboard, or one block of it, into a PNG: a chart to drop into a chat,
a doc or a slide, or a whole page to attach to a report. With an `--out` ending in `.pdf` it prints
the whole dashboard as a PDF report instead (see [PDF reports](#pdf-reports)), and it prints a
Markdown report from `reports/` the same way ([Reports](/docs/guides/reports.md)). The picture is the built page drawn by a
real browser, so it has the same fonts, colours and layout a reader sees at that width and theme.
Like every command it never asks questions and prints one line of JSON when an agent runs it.

```sh theme={null}
hatchmark render sales                                # the whole page, into sales.png
hatchmark render sales --block revenue_by_region      # one card, into sales.revenue_by_region.png
hatchmark render sales --theme dark --width 390       # the phone layout in dark mode
hatchmark render explorer --filter period=last_30_days --filter grain=day --out chart.png
hatchmark render sales --out sales.pdf                # a PDF report on Letter paper
hatchmark render sales --out sales.pdf --paper a4 --landscape --page-pngs
```

## Options

| Option | Meaning |
| - | - |
| `<dashboard>` | The dashboard name, its file name under `dashboards/`, or a report name, its file name under `reports/` without `.md`. |
| `--block <id>` | Render only this block's card instead of the whole page. KPIs, charts, tables and maps all work. The card is cut out of the page at the size it has there. |
| `--out <file>` | Where to write the PNG, relative to `--cwd`. Defaults to `<dashboard>.png`, or `<dashboard>.<block>.png` with `--block`. Missing directories are created. |
| `--width <px>` | The browser window width in CSS pixels, 320 to 3840, default 1280. The page picks the same layout it picks in a browser that wide, so 390 gives the phone layout. |
| `--scale <n>` | PNG only: device pixels per CSS pixel, 1 to 4, default 2. A page 1280 wide at scale 2 is a PNG 2560 pixels wide, sharp on high-density screens. |
| `--theme <light\|dark>` | The colour theme, default `light`. |
| `--filter <id>=<value>` | Set a dashboard filter to the value the page URL would carry. Repeat it for several filters. See [Filters](#filters). |
| `--paper <letter\|a4>` | PDF only: the paper size, default `letter`. A report's `pdf.paper` sets its default. |
| `--landscape` | PDF only: print the pages in landscape. A report with `pdf.landscape: true` prints in landscape without it. |
| `--page-pngs` | PDF only: also save each printed page as `<out>.page-<n>.png`. See [Looking at the pages](#looking-at-the-pages). |
| `--install-browser` | When no browser is found, download the Chromium headless shell once. See [The browser](#the-browser). |

A whole page is as tall as its content; the window height does not matter.

## Filters

`--filter` takes the same id and value as the dashboard's query parameter in the page URL, so
`--filter period=last_30_days` renders what `/explorer/?period=last_30_days` shows. The id is the
filter's `id` in the dashboard file (see [Dashboards](/docs/reference/dashboards.md)).

| Filter | Values |
| - | - |
| period | A preset the filter lists, such as `last_30_days`, or a custom range `<first>..<last>` of days, such as `2026-08-01..2026-09-30`, when it offers one. |
| grain | A grain key the filter lists, such as `day`, `week:sunday` or `month`. |
| segment | Segment names separated by commas, such as `americas,paid_marketing`, or an empty value for all rows. |
| select | One value the filter offers, such as `EMEA`. A filter without `options` also takes an empty value for all rows. |

A browser silently falls back to the default for a value it does not know. Render refuses it
instead, with `HM0002` and the values the filter accepts, so an agent can correct the call.
Filters that are not set keep their defaults. The theme is always `--theme`: `theme` is the page's own
URL parameter, and no filter may use it as its id (`HM2050`).

## PDF reports

`--out <file>.pdf` prints the whole dashboard as a report for people who read it away from the
dashboard: attached to an email, printed, or filed as the record of a month. It is the page a
reader sees, so the numbers are the same strings, and charts and text stay vector and selectable.

```sh theme={null}
hatchmark render sales --out reports/sales-2026-10.pdf
hatchmark render explorer --filter period=last_30_days --filter grain=week --out last-30-days.pdf
```

Printing changes how the page is laid out, not what it says:

* **Paper.** Letter by default, or `--paper a4`, portrait or `--landscape`, with half-inch margins.
  Portrait pages use the 720 px layout, where every block takes the full width; landscape pages use
  the 976 px layout with the dashboard's columns. A layout wider than the paper is shrunk to fit,
  never enlarged.
* **Cards stay whole.** A card or a KPI strip never splits across pages; it moves to the next page
  instead. A table taller than a page splits between rows, repeats its column headings on every
  page and prints its total row once, at the end.
* **Tables fit or say so.** A table wider than the page is shrunk, down to 80% of its size. If it is
  still too wide, the columns that do not fit are left out whole, never cut through a number; a line
  under the table names them, and render warns with `HM5060`.
* **Controls become a sentence.** The period picker, grain switches and segment chips print under
  the title as text stating what is selected, such as
  `Last 30 days (Oct 2 – 31, 2026) · Week · Data through Oct 31, 2026, 6:54 PM EDT`. Long segment labels wrap
  like any sentence. Filters apply as with PNGs. A tooltip or highlight left by the pointer is not
  printed.
* **Light theme, white paper.** A PDF is always light; `--theme dark` is refused. The page's grey
  background is not printed; cards keep their borders.
* **Footer.** Every page ends with the dashboard title, what the data runs through, and the page
  number, such as `Global sales · Data through Oct 31, 2026, 6:54 PM EDT` and `2 / 3`. The time
  shows only when the data ends partway through that day.

Problems render cannot fix on its own are warnings in the output, and the PDF is still written:

| Code | Problem |
| - | - |
| `HM5060` | A table is wider than the page even at 80%, so columns are left out. Print `--landscape`, or show fewer. |
| `HM5061` | A card is taller than a page, so it splits across pages. Give it a smaller `height` or split the group. |

### Looking at the pages

`--page-pngs` also saves each page of the PDF as a PNG next to it: `sales.pdf` gives
`sales.page-1.png`, `sales.page-2.png` and so on, at two device pixels per CSS pixel. The pictures are drawn
from the PDF itself, so they show exactly where pages break. An agent can look at them to check a
report before handing it over, without a PDF viewer. Drawing them uses PDF.js (Apache-2.0), which
ships inside Hatchmark.

### Same input, same bytes

Rendering the same dashboard with the same data, options and browser writes the same file, byte for
byte. Chromium stamps the time of printing into the PDF; render replaces it with midnight UTC on the
date the data runs through, so a new file means the report changed. The document title is the page
title, such as `Global sales · Global Sales`. A different browser version may lay text out slightly
differently, so pin `HATCHMARK_BROWSER` where the bytes must match across machines.

## Output

Human output names the file and its size in pixels. JSON output has the
[diagnostic report](/docs/reference/diagnostics.md) fields, with any warnings from the build, plus:

```json theme={null}
{
  "format_version": "1",
  "ok": true,
  "error_count": 0,
  "warning_count": 0,
  "diagnostics": [],
  "path": "sales.revenue_by_region.png",
  "dashboard": "sales",
  "block": "revenue_by_region",
  "width": 1280,
  "scale": 2,
  "theme": "light",
  "filters": {},
  "pixel_width": 1636,
  "pixel_height": 732,
  "browser": { "source": "chromium-headless-shell", "version": "159.0.8154.6" }
}
```

`path` is relative to `--cwd` when the file is inside it. `block` is present only with `--block`.

For a PDF the output names the paper and the pages instead of the pixels:

```json theme={null}
{
  "format_version": "1",
  "ok": true,
  "error_count": 0,
  "warning_count": 0,
  "diagnostics": [],
  "path": "sales.pdf",
  "dashboard": "sales",
  "paper": "letter",
  "landscape": false,
  "filters": {},
  "page_count": 3,
  "shrunk_tables": [],
  "page_pngs": ["sales.page-1.png", "sales.page-2.png", "sales.page-3.png"],
  "browser": { "source": "chromium-headless-shell", "version": "159.0.8154.6" }
}
```

`shrunk_tables` lists each table printed smaller to fit the page, with its `scale` from 0.8 to 1.
`page_pngs` is present only with `--page-pngs`.

## What it does

1. Loads and checks the project, then runs the dashboard's queries the way `hatchmark build` does,
   reusing results from the [build cache](/docs/reference/build.md#build-cache). Errors stop it before anything is
   drawn, with the same diagnostics and exit codes as build.
2. Renders the page `build` would write, with the same runtime and fonts, and serves it to the
   browser from memory. Nothing is written to `outDir`.
3. Opens the page at the width, scale and theme, applies the filters as the page does on load, waits
   for the fonts and for filters that redraw the page, and saves the screenshot.

## The browser

Render needs a Chromium-based browser and looks for one in this order:

1. The executable `HATCHMARK_BROWSER` names, such as a Chrome or Chromium binary. If it does not
   start, render stops with `HM0011` rather than trying another browser.
2. The Chromium headless shell in Playwright's browser cache, when it is already there
   (`~/Library/Caches/ms-playwright` on macOS, `~/.cache/ms-playwright` on Linux, or
   `PLAYWRIGHT_BROWSERS_PATH`).
3. An installed Google Chrome, then Microsoft Edge.

On most machines Chrome or Edge is already installed, and render downloads nothing. When none is
found it exits 3 with `HM0011`. Rerun with `--install-browser` to download the Chromium headless
shell once, about 106 MB on macOS and 132 MB on Linux. Render never downloads without that flag.

A browser draws pages, and Hatchmark pages are HTML and CSS around SVG charts. That is why render
uses one rather than an SVG rasterizer: a rasterizer can draw a chart's SVG but not the KPI cards,
tables, page grid or filter controls around it, so its pictures would not match the page. Driving the
browser adds about 14 MB to the install (`playwright-core`, with no browser inside).

## Accuracy

The test suite renders pages and cards with filters, themes and widths from 390 to 1440 pixels, and
compares each PNG with a screenshot of the page `build` wrote, opened in the same browser. This is
done twice, with the Chromium headless shell and with a full Chrome build through
`HATCHMARK_BROWSER`. The PNG must have exactly the browser's size, and at most 0.1% of its pixels may
differ by more than 24 of 255 on any colour channel. In practice none do.

PDFs are checked by their text: the tests print dashboards on Letter and A4, portrait and
landscape, with filters, extract the PDF's text, and require exactly the numbers the page shows in
the browser's print layout, each as often. They also check the paper size, the footer on every
page, the page pictures, and that two renders write the same bytes.

Different browser builds draw text slightly differently, and on Linux the headless shell and full
Chrome place glyphs a fraction of a pixel apart. To match a particular browser exactly, point
`HATCHMARK_BROWSER` at it.

## Exit codes

| Code | Meaning |
| - | - |
| 0 | The PNG or PDF was written. Warnings are allowed. |
| 1 | Errors in your files, as in `build`. |
| 2 | Usage error: no or unknown dashboard, block or filter, a value out of range, an option for the other format, or errors in `hatchmark.yaml`. |
| 3 | Environment problem: no browser to render with (`HM0011`), or a data file that does not exist. |
| 4 | Internal bug in Hatchmark, such as a page error or a page that does not finish drawing within 30 s. Please report it. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.