TypeAnvil is an open-source HTML → PDF typesetting engine written in Rust. It turns HTML documents with paged-media CSS into production PDFs for reports, invoices, letters, papers, and books.
It is built for developers who need print-quality pagination without a commercial rendering engine or a headless browser farm.
- Deterministic output. Identical input produces byte-identical PDFs. Diff-test your documents in CI.
- Typography by default. Measured text shaping, line breaking, hyphenation, and widow/orphan handling are part of the engine's typography pipeline.
- Paged-media CSS support. The engine supports
@pagerules with margin boxes, named pages, page counters, running headers, footnotes, leader fills, multi-column layout, floats, and repeating table headers and footers. See the feature specifications for exact behavior and known gaps. - Accessibility features. PDFs carry a tagged structure tree by
default (
--no-taggedturns it off);--uaadditionally validates against PDF/UA-1.
PrinceXML and Chromium are comparison tools. CSS specifications define TypeAnvil's expected behavior.
Build from source with a current stable Rust toolchain:
git clone https://github.com/winterloom/typeanvil
cd typeanvil
cargo build --release --manifest-path engine/Cargo.tomlRender a document:
./engine/target/release/typeanvil render input.html \
--page-width 8.5in --page-height 11in \
--margin-top 1in --margin-right 1in \
--margin-bottom 1in --margin-left 1in \
-o output.pdfThe full flag reference is in docs/operations/cli.md. The architecture overview explains the pipeline and module boundaries.
A report with chapter headers in the page margin and page numbers in the footer:
<!DOCTYPE html>
<html>
<head>
<style>
@page {
size: Letter;
margin: 1in;
@top-left { content: string(chapter); font-size: 9pt; color: #666; }
@bottom-center { content: "Page " counter(page) " of " counter(pages); }
}
h1 { string-set: chapter content(); }
table { border-collapse: collapse; width: 100%; }
th { background: #eee; }
thead { display: table-header-group; }
</style>
</head>
<body>
<h1>Quarterly Report</h1>
<p>Long content flows across pages with running headers and table pagination.</p>
<table><!-- rows spanning many pages --></table>
</body>
</html>The CLI accepts standalone HTML files and Markdown files. Inline <style>
elements and local linked stylesheets are supported. JavaScript is not executed.
A file with the extension .md, .markdown or .mdown is read as Markdown.
The engine converts it to HTML and applies a built-in stylesheet, so the PDF
looks finished with no CSS. YAML frontmatter sets the PDF title and author.
---
title: Release Notes
author: A. Author
---
# Release Notes
| Item | Status |
|---------|--------|
| Parser | done |
| Layout | done |
A note with a footnote.[^1]
[^1]: Footnotes print at the bottom of the page.typeanvil render notes.md \
--page-width 8.5in --page-height 11in \
--margin-top 1in --margin-right 1in --margin-bottom 1in --margin-left 1in \
-o notes.pdfAdd your own CSS with --css style.css, or drop the built-in stylesheet with
--no-default-css. See the Markdown to PDF guide.
See the specifications for exact contracts and known gaps. The WPT harness and release gate describe verification.
Rendered output for every release lives in the typeanvil-showcase repo and on its Pages site. The latest version link stays stable.
- Architecture overview
- CLI reference
- Feature specifications
- Contributor and development guidelines
- Documentation site
TypeAnvil is free software under the AGPL-3.0-only license. The engine has no license check, watermark, activation flow, phone-home behavior, or feature gate. Read CLA.md for contribution terms.
This repository documents the engine and its tooling. Public documentation for a hosted service will be linked separately when available.