Home

PDF Theme Target

Overview

PDF output is produced by rendering the document as HTML with print media styles enabled. Theme tokens in pages.css and module-level @media print rules define page size, margins, headers/footers, and print-specific styling.

This translation happens whenever you create a PDF with Stencila, for example using the CLI's render command:

stencila render report.smd report.pdf

Paged Media Tokens

Paged media tokens come from pages.css and are documented here. These tokens map directly into CSS @page rules that are respected by the PDF renderer.

Page Size and Margins

TokensPDF output
--page-width, --page-height@page size
--page-margin-*Page margins
--page-padding-*Padding between content and margin boxes

Header/Footer (Margin Boxes)

TokensPDF output
--page-top-*-content, --page-bottom-*-contentMargin box content
--page-margin-font-family, --page-margin-font-sizeMargin box typography
--page-margin-color, --page-margin-line-heightMargin box text styles
--page-border-*Header/footer rules

First-Page Overrides

TokensPDF output
--page1-*First-page margin box overrides

Print Variants

Component modules include @media print variants (e.g. tables, figures, code) to adjust styling specifically for PDF/print output. Where available, *-print tokens are used to override screen defaults for print.

Implementation Notes

  • The PDF renderer uses print media and honors @page rules (see html_to_png.rs).

  • Paged media tokens live in pages.css and are documented in site/docs/themes/tokens/print.smd.

© 2026 Stencila