Skip to content
winterloomPublic

About

Open-source HTML to PDF engine with paged-media CSS, written in Rust. A PrinceXML and headless-Chrome alternative.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

TypeAnvil

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.

Why TypeAnvil

  • 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 @page rules 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-tagged turns it off); --ua additionally validates against PDF/UA-1.

PrinceXML and Chromium are comparison tools. CSS specifications define TypeAnvil's expected behavior.

Getting started

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.toml

Render 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.pdf

The full flag reference is in docs/operations/cli.md. The architecture overview explains the pipeline and module boundaries.

Usage example

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.

Markdown example

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.pdf

Add your own CSS with --css style.css, or drop the built-in stylesheet with --no-default-css. See the Markdown to PDF guide.

Feature status

See the specifications for exact contracts and known gaps. The WPT harness and release gate describe verification.

Showcase

Rendered output for every release lives in the typeanvil-showcase repo and on its Pages site. The latest version link stays stable.

Documentation

License

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.

About

Open-source HTML to PDF engine with paged-media CSS, written in Rust. A PrinceXML and headless-Chrome alternative.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages