CASOON Open Source
Typst in, PDF out.
typstgen compiles an existing .typ file to PDF with the Typst engine built in: no typst binary, no subprocess. Template directories come from a config file instead of hardcoded paths.
cargo install typstgencargo install --git https://github.com/casoon/typstgencargo add typstgen --no-default-featuresCompile a single .typ file to PDF
Usage: typstgen compile [OPTIONS] <INPUT>
Arguments:
<INPUT> Path to the .typ file
Options:
-o, --output <OUTPUT>
Output PDF path (defaults to input with .pdf extension)
-c, --config <CONFIG>
Path to typstgen.toml (defaults to ./typstgen.toml if present)
--input <KEY=VALUE>
Add a string key-value pair visible through `sys.inputs`
--pdf-standard <STANDARD>
PDF standards to enforce, comma-separated (e.g. a-2b, ua-1, 1.7)
--creation-timestamp <UNIX_SECONDS>
Creation date as a Unix timestamp; also used by datetime.today() [env: SOURCE_DATE_EPOCH=]
--pages <PAGES>
Pages to export, comma-separated (e.g. 1-3,5,8-); implies an untagged PDF
--no-pdf-tags
Write an untagged PDF (smaller, but without document structure)
-h, --help
Print help- external typst binaries or subprocesses
- 0
- bundled font files, also in Wasm
- 17
- entry points: CLI, Rust library, Wasm
- 3
- keys in typstgen.toml
- 3
What it does
Typst as a library
typst and typst-pdf 0.15 are compiled into typstgen. The CLI writes the PDF; the library returns its bytes.
Template paths from config
typstgen.toml lists template directories. Each import is looked up next to the document first, then in every template directory in order. None of them is required.
Fonts you can rely on
Typst’s fallback fonts are always bundled. Turn system fonts off and add project fonts, and the same input gives the same PDF on every machine.
Runs in Wasm
The wasm feature takes the source and its imports as a JSON virtual filesystem and returns the PDF bytes. No filesystem needed.
Compiled by typstgen
All examples →Open letter.pdf · Download letter.pdf (19.2 KiB)
examples/letter.typ imports a template from examples/templates/. typstgen compiled it to this PDF; examples/regenerate.sh rebuilds all fixtures with the current CLI.
examples/letter.pdfQuickstart
Three steps from a .typ file to a PDF. The documentation covers template lookup, fonts and the config file.
- Install the CLI with
cargo install typstgen. - List your template directories in
typstgen.toml. - Run
typstgen compileon your document.
# typstgen.toml
template_paths = ["templates"]
# letter.typ imports templates/letterhead.typ
typstgen compile letter.typ
# → letter.pdf