Skip to Content
DocumentationConceptsEditorHow rendering works

The reason your PDF looks like the editor preview isn’t luck — both surfaces consume the same source through the same renderer. This page explains what that means in practice, where styling decisions get resolved, and a handful of gotchas worth knowing if you’ve spent too much time chasing why a margin or a font size isn’t behaving.

One source, two surfaces

Every MakeBox template lives as an editor_value — a structured array of blocks (headings, paragraphs, tables, callouts, …). The editor doesn’t store HTML; it stores blocks. The PDF doesn’t render from a separate template; it renders from the same blocks.

Two surfaces consume those blocks:

SurfaceHow blocks become pixels
Editor previewA shared renderer turns blocks into HTML. You see it live as you edit
PDF outputThe same renderer runs server-side to emit HTML, then headless Chromium prints that HTML to PDF

Both paths start at the same editor_value array and walk through the same renderer. The PDF doesn’t go through a different pipeline; it just adds a final “now print this HTML” step at the end. That’s the structural reason the preview matches the output — visual fidelity isn’t a goal we chase, it’s a property of running the same code on the same input.

Where styling decisions come from

Styles aren’t free-floating CSS. They resolve through a layered model:

per-block overrides (a specific block has its own font-size set) ↓ per-template styles (this whole template uses a smaller body font) ↓ brand theme (your workspace's brand colors + fonts) ↓ fallback defaults (system defaults; what every block gets if nothing above it set anything)

Higher layers override lower layers. Per-block always wins. Fallback defaults are the floor — even an empty template renders with usable typography because the defaults are sensible.

See How styling works for the full layered model, the AI-vs-UI ways to change styles, and the brand-theme override path. That page is the styling source-of-truth; this page just notes the layers exist.

How a single block becomes a page

For each block in editor_value:

  1. The renderer resolves the block’s effective style by walking the four layers above. Per-block first, then per-template, then brand, then defaults
  2. The renderer emits the block’s HTML with the resolved styles inlined (or referenced via class names that resolve at render time)
  3. The renderer respects block-level layout hints — is_fixed_band, page-break, alignment, indent, etc.
  4. The next block runs through the same pipeline

There’s no “second pass.” Styles aren’t injected after layout; they’re baked in at the moment each block is rendered. This is why per-block overrides are predictable — the override only affects that one block, not its neighbors.

Multi-page

Most documents fit on one page. When they don’t, the renderer paginates automatically:

  • Auto-pagination — the renderer estimates the cumulative height of each block. When the running total exceeds the page budget, the next block moves to a new page. The estimate is server-side and intentionally conservative — the renderer would rather break a page slightly early than risk content overflowing
  • is_fixed_band markers — blocks at the top of the editor_value can carry is_fixed_band: true. Those blocks render at the top of every page (think: invoice header with logo + company info). Auto-pagination subtracts the band’s height from the available body budget
  • Explicit page-break blocks — for hand-controlled multi-page templates, the author can insert a block with type: "page-break". The renderer treats it as an unconditional new-page signal
  • Orphan headings — if a page would end with a heading and no body content beneath it, the renderer pulls the heading forward to the next page. Section headings stay with the content they introduce

You can mix these. A common pattern: a fixed band at the top, then auto-pagination for the body, then an unconditional page-break before terms and conditions so they always start fresh.

Common gotchas

A few things catch people:

  • marginTop and marginBottom are not what the renderer reads. The renderer reads spacingBefore and spacingAfter. If you set marginTop on a heading and nothing happens, that’s why. Use spacingBefore / spacingAfter instead
  • hr ignores spacing props. Horizontal rules render with their own internal spacing. Setting spacingBefore on an hr has no effect; if you need a bigger gap above an hr, insert an empty paragraph with lineHeight set high enough to act as a spacer
  • Print font sizes are in pt, screen font sizes are in px. The renderer handles the conversion, but if you’re setting font size manually and you mean print size, use pt units. 12pt is the standard body size for documents; that’s roughly 16px on screen at 96 dpi
  • Tables with repeat: "items" rows render once per array entry. If your data array is empty, the table renders zero rows — not “one row showing the placeholder.” This matters when previewing with sample data: a record with items: [] renders an empty table; a record with items: [{...}, {...}] renders a two-row table
  • Variables that don’t resolve render as {{variable_name}} literally. If you typo a name, the literal appears in the output (open the rendered PDFs from a Test Run in the pipeline editor to catch it before a real run). Always check the Variables panel → Schema fields for the canonical names

Most of these gotchas are inherited from the renderer’s internal naming or from years of practical pain. They’ll get smoothed over time; for now, knowing them saves debugging hours.

What this doesn’t cover

  • The PDF service’s exact Chromium settings — page size, DPI, color profile. These are infrastructure constants from STYLE_TOKENS.infrastructure; they exist but aren’t user-tunable
  • How the AI assistant changes styles in response to natural-language prompts — that’s the AI’s interface to the same rendering pipeline, covered in How to tell the AI to change template styles (Phase 3a, coming soon)
  • Fidelity check internals — MakeBox runs internal checks comparing the editor preview to the PDF output to catch drift. These are internal tooling, not a user-facing feature
Last updated on