Skip to main content

Crate typstgen

Crate typstgen 

Source
Expand description

§typstgen

Compile an existing .typ file to PDF using an embedded Typst engine — no external typst binary, no subprocess. Template resolution is config-driven (see Config) rather than hardcoded.

Usable as a CLI (cli feature), a Rust library (always), and from JavaScript via Wasm (wasm feature).

ⓘ
use typstgen::{compile, Config};

let config = Config::load(None)?;
let pdf_bytes = compile("example.typ".as_ref(), &config)?;
std::fs::write("example.pdf", pdf_bytes)?;

Re-exports§

pub use config::Config;
pub use error::Error;
pub use error::Result;
pub use options::CompileOptions;
pub use options::PageRange;
pub use options::PdfStandard;

Modules§

config
Config-driven template path resolution.
error
The error type returned by every fallible typstgen function.
options
Per-compilation options: sys.inputs and PDF export settings.

Structs§

Output
A compiled PDF together with the warnings Typst reported.

Functions§

compile
Compile a .typ file to PDF bytes using the embedded Typst engine.
compile_with_options
Like compile_with_warnings, with sys.inputs and PDF export settings from CompileOptions.
compile_with_warnings
Like compile, but also returns Typst’s warnings.