Install GlyphWeaveForge and convert your first Markdown file to PDF in minutes.
Add to your Cargo.toml:
[dependencies]
glyphweaveforge = "0.1"
For Typst backend (recommended for production):
[dependencies]
glyphweaveforge = { version = "0.1", features = ["renderer-typst"] }
Create a Forge builder, feed it markdown text, and call .convert():
use glyphweaveforge::Forge;
fn main() {
let pdf = Forge::new()
.from_text("# Hello\n\nThis is **bold** text.")
.to_memory()
.convert()
.expect("conversion succeeded");
// pdf.bytes contains the raw PDF data
assert!(pdf.bytes.unwrap().starts_with(b"%PDF"));
}
Read Markdown from disk and save the PDF to a file:
use glyphweaveforge::Forge;
fn main() {
Forge::new()
.from_path("README.md")
.to_file("output.pdf")
.convert()
.expect("conversion succeeded");
}
Six built-in themes. Pass them via .with_theme():
use glyphweaveforge::{Forge, BuiltInTheme};
fn main() {
Forge::new()
.from_text("# Engineering Report")
.to_file("report.pdf")
.with_theme(BuiltInTheme::Engineering)
.convert()
.expect("conversion succeeded");
}
Available themes: Professional (default), Engineering, ScientificArticle, Invoice, Informational.
Enable renderer-typst for professional typesetting with real math, custom fonts, and Mermaid diagrams:
use glyphweaveforge::{Forge, RenderBackendSelection, BuiltInTheme};
fn main() {
Forge::new()
.from_file("paper.md")
.to_file("paper.pdf")
.with_backend(RenderBackendSelection::Typst)
.with_theme(BuiltInTheme::ScientificArticle)
.convert()
.expect("conversion succeeded");
}
Resolve image paths dynamically — load from disk, a CDN, or generate on the fly:
use glyphweaveforge::Forge;
fn main() {
let pdf = Forge::new()
.from_text("")
.to_memory()
.with_resource_resolver(|href: &str| {
if href == "logo.png" {
Ok(vec![1, 2, 3]) // real bytes here
} else {
Err("not found".into())
}
})
.convert()
.expect("conversion succeeded");
}
| Flag | Description |
|---|---|
default = ["fs", "renderer-minimal"] | File I/O + minimal backend |
fs | Enables from_path(), to_file(), to_dir() |
renderer-minimal | Lightweight native renderer (no system deps) |
renderer-typst | Typst backend (real math, fonts, Mermaid) |
typst | Alias for renderer-typst |
math | GFM math parsing + TeX-to-Typst conversion |
mermaid | Rust-native Mermaid diagram renderer |