Professional document generation for small businesses — as a Rust library or standalone CLI.
Generate invoices, offers, contracts and more as PDF without a running Typst installation. Templates, fonts and localization are embedded directly in the binary.
Created by casoon.de.
Add to your Cargo.toml:
[dependencies]
typst-business-templates = "0.1"use typst_business_templates::{
DocgenCompiler, CompanyData, CompanyAddress, CompanyContact,
InvoiceData, InvoiceMetadata, InvoiceRecipient, InvoiceItem,
};
fn main() -> anyhow::Result<()> {
let company = CompanyData {
name: "Mustermann IT-Services".into(),
language: "de".into(),
address: CompanyAddress {
street: "Musterstraße".into(),
house_number: "1".into(),
postal_code: "12345".into(),
city: "Berlin".into(),
country: Some("Deutschland".into()),
},
contact: CompanyContact {
email: Some("[email protected]".into()),
..Default::default()
},
..Default::default()
};
let invoice = InvoiceData {
metadata: InvoiceMetadata {
invoice_number: "RE-2024-001".into(),
invoice_date: "01.01.2024".into(),
due_date: "15.01.2024".into(),
..Default::default()
},
recipient: InvoiceRecipient {
name: "Kunde GmbH".into(),
company: Some("Kunde GmbH".into()),
address: typst_business_templates::types::RecipientAddress {
street: "Kundenstraße".into(),
house_number: "42".into(),
postal_code: "10115".into(),
city: "Berlin".into(),
country: None,
},
},
items: vec![InvoiceItem {
position: 1,
description: "Webentwicklung".into(),
quantity: 8.0,
unit: "h".into(),
vat_rate: typst_business_templates::types::VatRate { percentage: 19 },
unit_price: typst_business_templates::types::MoneyAmount { amount: 90.0, currency: None },
total: typst_business_templates::types::MoneyAmount { amount: 720.0, currency: None },
sub_items: vec![],
}],
totals: typst_business_templates::types::InvoiceTotals {
subtotal: typst_business_templates::types::MoneyAmount { amount: 720.0, currency: None },
vat_breakdown: vec![typst_business_templates::types::VatBreakdownItem {
rate: 19,
base: typst_business_templates::types::MoneyAmount { amount: 720.0, currency: None },
amount: typst_business_templates::types::MoneyAmount { amount: 136.80, currency: None },
}],
total: typst_business_templates::types::MoneyAmount { amount: 856.80, currency: None },
},
payment: typst_business_templates::types::InvoicePayment {
due_date: "15.01.2024".into(),
bank_transfer_note: None,
},
salutation: None,
closing: None,
};
let pdf = DocgenCompiler::new().compile_invoice(&invoice, &company)?;
std::fs::write("rechnung.pdf", pdf)?;
println!("PDF generated: rechnung.pdf");
Ok(())
}| Template name | Document type |
|---|---|
invoice |
Rechnung / Invoice |
offer |
Angebot / Offer |
contract |
Vertrag / Contract |
credentials |
Zugangsdaten / Credentials |
concept |
Konzept / Concept |
documentation |
Dokumentation / Documentation |
diagram |
Diagramme / Diagrams |
letter |
Brief / Letter |
delivery-note |
Lieferschein / Delivery Note |
credit-note |
Gutschrift / Credit Note |
reminder |
Mahnung / Reminder |
For templates other than invoice, use the generic compile() method:
let pdf = DocgenCompiler::new().compile(
"offer",
serde_json::to_vec(&offer_data)?,
&company,
"de",
)?;For diagrams, pass a JSON structure with nodes, edges, and layout metadata:
let pdf = DocgenCompiler::new().compile(
"diagram",
std::fs::read("examples/diagram-flow/diagram.json")?,
&company,
"de",
)?;By default, system fonts are used. To load additional fonts:
let compiler = DocgenCompiler::new()
.with_fonts_dir("/path/to/fonts");Professional document generation for small businesses without expensive software.
Stop paying for bloated invoice and document software. This open-source solution combines:
- Typst - Modern markup language for beautiful PDFs
- JSON Data Format - Simple, human-readable data for your documents
- AI-Powered Creation - Use Claude or other LLMs to generate content
- Interactive CLI - Manage clients, projects, and documents from your terminal
Perfect for freelancers, agencies, and small businesses who want full control over their documents.
| Traditional Software | This Solution |
|---|---|
| Monthly subscriptions | Free & open source |
| Vendor lock-in | Your data in plain JSON |
| Limited customization | Full template control |
| Cloud dependency | Works offline |
| Complex interfaces | Simple CLI + AI |
While templates are built with Typst, the docgen CLI simplifies everything:
# With docgen - just point to your JSON
docgen compile invoice.json
# With raw typst - you handle all the paths
typst compile --root . --font-path fonts templates/invoice/default.typ output/invoice.pdf \
--input data=/path/to/invoice.json --input company=/path/to/company.jsondocgen auto-detects document type, finds templates, loads fonts, and places output correctly.
Instead of clicking through forms, describe what you need:
"Create an invoice for client Acme Corp for 40 hours of web development
at 85 EUR/hour, project was the new landing page, payment due in 14 days"
An AI assistant (we recommend Claude) generates the JSON, you review it, and compile to PDF. Fast, flexible, and you stay in control.
- Invoice Template - Professional German invoices with VAT calculation
- Offer Template - Quotes and proposals with item breakdowns
- Credentials Template - Secure access documentation for clients
- Concept Template - Project concepts and proposals
- Documentation Template - Technical documentation, API docs, project docs
- Diagram Template - Mindmaps, flowcharts, org charts, and simple software architecture diagrams
- Simple CLI - Manage clients, projects, and create documents
- JSON Data Storage - Human-readable data files with automatic numbering
- Direct .typ File Support - Write documents directly in Typst without JSON
- Project-Local Templates - Standard templates auto-update, fork for customization
- Watch Mode - Auto-rebuild on file changes
- 10 Font Presets - Bundled Google Fonts (Inter, Roboto, Montserrat, etc.)
- Customizable Branding - Colors, fonts, logo via company.json
Install Typst (required for PDF generation)
# Add the tap
brew tap casoon/tap
# Install docgen
brew install docgencurl -fsSL https://raw.githubusercontent.com/casoon/typst-business-templates/main/install.sh | bashDownload the latest release for your platform from GitHub Releases.
| Platform | Download |
|---|---|
| macOS (Apple Silicon) | docgen-aarch64-apple-darwin.tar.gz |
| macOS (Intel) | docgen-x86_64-apple-darwin.tar.gz |
| Linux (x64) | docgen-x86_64-unknown-linux-gnu.tar.gz |
| Linux (ARM64) | docgen-aarch64-unknown-linux-gnu.tar.gz |
| Windows (x64) | docgen-x86_64-pc-windows-msvc.zip |
# Clone repository
git clone https://github.com/casoon/typst-business-templates.git
cd typst-business-templates
# Build CLI
cd cli
cargo build --release
# Add to PATH (optional)
export PATH="$PATH:$(pwd)/target/release"# Initialize new project
docgen init my-business
cd my-business
# Edit your company data
nano data/company.json
# Add a client
docgen client add --name "Acme Corp"
# See all commands
docgen --helpdocgen can now generate diagram PDFs from JSON without manual positioning or external Typst packages.
Supported diagram styles:
tree/hierarchicalflow/layeredmindmap/radialarchitecture/layeredtimelineswimlanequadrantroadmap
Example:
docgen compile examples/diagram-flow/diagram.json -o output/diagram.pdfAvailable showcase examples:
examples/diagram-flow/diagram.jsonexamples/diagram-mindmap/diagram.jsonexamples/diagram-orgchart/diagram.jsonexamples/diagram-architecture/diagram.jsonexamples/diagram-timeline/diagram.jsonexamples/diagram-swimlane/diagram.jsonexamples/diagram-quadrant/diagram.jsonexamples/diagram-roadmap/diagram.json
Templates live in your project directory for maximum portability:
project/
├── .docgen/templates/ # Standard templates (auto-updated)
│ ├── concept/
│ ├── invoice/
│ └── ...
├── templates/ # Your custom templates (stable)
│ └── my-custom-concept/
├── data/
│ ├── company.json
│ └── logo.png
└── documents/
Initialize templates:
docgen template initStandard Templates (.docgen/templates/)
- Auto-updated on every
docgen compileordocgen build - Always match your docgen version
- Never committed to Git (in
.gitignore) - Perfect for standard business documents
Custom Templates (templates/)
- Fork from standard templates when you need customization
- Stable - never auto-updated
- Committed to Git - part of your project
- Full control over layout and structure
// Standard template (auto-updated)
#import "/.docgen/templates/concept/default.typ": concept
// Custom template (stable)
#import "/templates/my-custom-concept/default.typ": my_custom_concept
// Load company and locale data
#let company = json("/data/company.json")
#let locale = json("/locale/de.json")
#show: concept.with(
title: "Cloud Migration Strategy",
document_number: "DOC-2025-001",
client_name: "Example Corp",
project_name: "Cloud Transformation",
version: "1.0",
status: "final",
company: company,
locale: locale,
)
= Current Situation
The client currently uses an outdated email infrastructure...
= Proposed Solution
Migration will be performed in multiple phases:
1. Inventory of existing email addresses
2. Setup of new mail server infrastructure
3. Mailbox migration
4. DNS switchoverCompile with:
docgen compile documents/concepts/2025/email-migration.typ# Initialize project templates
docgen template init
# List available templates
docgen template list
# Fork a standard template to customize it
docgen template fork concept --name my-custom-concept
# Update standard templates (normally automatic)
docgen template updateWorkflow: Customizing a Template
-
Fork the template:
docgen template fork invoice --name branded-invoice
-
Edit
templates/branded-invoice/default.typ:// Add your custom styling #let primary-color = rgb("#FF6B35") // ... customize as needed
-
Commit to Git:
git add templates/branded-invoice/ git commit -m "Add custom branded invoice template" -
Use in your documents:
#import "/templates/branded-invoice/default.typ": invoice
Benefits:
- ✅ Everything in your project - works on any machine
- ✅ No system-wide package installation
- ✅ Commit custom templates to Git
- ✅ Standard templates always current
- ✅ Break-change protection - custom templates stay stable
Simple, direct commands for managing your business data:
# Manage clients
docgen client list
docgen client add --name "Acme Corp" --company "Acme Corporation GmbH"
docgen client show K-001
# Manage projects
docgen project list K-001
docgen project add K-001 "Website Redesign"
# Compile documents
docgen compile documents/invoices/RE-2025-001.json
docgen build documents/invoices/2025/
docgen watch documents/All data stored in human-readable JSON files:
data/clients.json- Your clientsdata/projects.json- Your projectsdata/counters.json- Auto-incrementing numbers
-
Describe your document to an AI assistant:
Create a JSON invoice for: - Client: K-001 (Acme Corp) - 3 items: - 40h Development @ 85 EUR - 8h Code Review @ 85 EUR - 500 EUR fixed for deployment - Due in 14 days -
AI generates the JSON following the schema in
cli/templates/invoice.json -
Save and compile:
docgen compile documents/invoices/RE-2025-001.json
-
PDF ready in
output/RE-2025-001.pdf
For power users - copy a template, edit the JSON directly:
cp cli/templates/invoice.json documents/invoices/RE-2025-001.json
nano documents/invoices/RE-2025-001.json
docgen compile documents/invoices/RE-2025-001.json| Command | Description |
|---|---|
docgen |
Show help |
docgen init <name> |
Create new project |
docgen compile <file> |
Compile JSON or .typ file to PDF (add --encrypt for password protection) |
docgen build [path] |
Build all documents (.json and .typ files) in directory |
docgen watch [path] |
Watch and auto-rebuild on changes |
docgen client list |
List all clients |
docgen client add --name "Name" |
Add new client (requires --name parameter) |
docgen client show <id> |
Show client details |
docgen project list <client> |
List projects |
docgen project add <client> <name> |
Add project |
docgen template init |
Initialize project templates |
docgen template list |
List standard and custom templates |
docgen template fork <name> --name <custom> |
Fork and customize a template |
docgen template update |
Update standard templates to current version |
Protect sensitive documents (like credentials) with password encryption:
# Compile with encryption
docgen compile documents/credentials/2026/client-access.json --encrypt
# Enter password (will be visible): [type password]Default permissions:
- Allow printing: yes
- Allow copying text/images: no
- Allow modifications: no
- Allow document modification? (default: no)
Requirements:
- Requires
qpdfto be installed - Installation:
- macOS:
brew install qpdf - Linux:
apt-get install qpdf(Debian/Ubuntu) oryum install qpdf(RHEL/CentOS) - Windows:
choco install qpdf - Or download from: https://github.com/qpdf/qpdf/releases
- macOS:
Features:
- AES-256 encryption (industry standard)
- Password protection
- Configurable permissions (print, copy, modify)
- Compatible with all PDF readers
my-business/
├── data/
│ ├── clients.json # Your clients (human-readable)
│ ├── projects.json # Your projects (human-readable)
│ ├── counters.json # Auto-incrementing numbers
│ └── company.json # Your company data & settings
├── documents/
│ ├── invoices/
│ │ ├── 2025/ # Organized by year
│ │ └── 2026/
│ ├── offers/
│ │ └── 2026/
│ ├── credentials/
│ │ └── 2026/
│ ├── concepts/
│ │ └── 2026/
│ └── documentation/
│ └── 2026/
├── .docgen/templates/ # Standard templates (auto-updated)
├── templates/ # Your custom templates
└── output/
└── 2026/ # PDFs organized by year
Automatic, consistent numbering managed by data/counters.json:
| Type | Format | Example |
|---|---|---|
| Client | K-XXX | K-001 |
| Project | P-KKK-NN | P-001-01 |
| Invoice | RE-YYYY-NNN | RE-2025-001 |
| Offer | AN-YYYY-NNN | AN-2025-001 |
| Credentials | ZD-YYYY-NNN | ZD-2025-001 |
| Concept | KO-YYYY-NNN | KO-2025-001 |
The examples/ directory contains complete, ready-to-use example projects for different types of businesses. Each project is self-contained with its own company data, documents, templates, and locales - just like a real project created with docgen init.
See examples/README.md for detailed information about each project.
Pixelwerk Digitalagentur - Full-service web agency from Cologne
Complete project with 5 documents (Invoice, Offer, Credentials, Concept, Documentation) demonstrating both JSON and .typ workflows.
Lisa Chen Design - Freelance graphic designer from Hamburg
Demonstrates Kleinunternehmer setup (§19 UStG - no VAT). Includes invoices, offers, and credentials.
TechVision Consulting - IT consulting firm from Berlin
Demonstrates regular business with 19% VAT. Includes security audits, penetration testing, and consulting services.
# Compile any document from an example project
cd examples/digitalagentur
docgen build
# Or compile a specific document
docgen compile documents/invoices/2025/invoice.jsonTemplates are written in Typst, a modern alternative to LaTeX.
To customize a template:
- Fork it:
docgen template fork invoice --name my-invoice - Edit:
templates/my-invoice/default.typ - Commit:
git add templates/my-invoice/ - Use:
#import "/templates/my-invoice/default.typ": invoice
Standard templates (.docgen/templates/) are auto-updated and should not be edited.
Custom templates (templates/) are yours to modify and version control.
The company.json file contains all business settings:
{
"name": "Your Company",
"language": "de",
"branding": {
"accent_color": "#E94B3C",
"primary_color": "#2c3e50",
"font_preset": "inter"
},
"numbering": {
"year_format": "short",
"prefixes": {
"invoice": "RE",
"offer": "AN",
"credentials": "ZD",
"concept": "KO"
}
},
"structure": {
"organize_by_year": true
},
"default_terms": {
"hourly_rate": "95.00",
"currency": "EUR",
"payment_days": 14,
"vat_rate": 19,
"standard_terms": [
"All prices are net plus VAT.",
"Payment due within 14 days."
]
}
}| Section | Purpose |
|---|---|
branding |
Colors, fonts, logo |
numbering |
Document number prefixes (RE, AN, ZD, KO) |
structure |
Organize documents by year |
default_terms |
Rates, payment terms, standard conditions |
Both the CLI and document templates support 7 languages:
| Code | Language |
|---|---|
de |
Deutsch (German) |
en |
English |
fr |
Français (French) |
es |
Español (Spanish) |
it |
Italiano (Italian) |
nl |
Nederlands (Dutch) |
pt |
Português (Portuguese) |
Set the language field in company.json to change all labels, headings, and CLI output.
10 professional Google Font combinations are available:
| Preset | Body/Heading | Mono | Style |
|---|---|---|---|
inter |
Inter | JetBrains Mono | Modern, clean |
roboto |
Roboto | Roboto Mono | Google's signature |
open-sans |
Open Sans | Source Code Pro | Friendly |
lato |
Lato | Fira Code | Elegant |
montserrat |
Montserrat | Fira Code | Geometric |
source-sans |
Source Sans 3 | Source Code Pro | Professional |
poppins |
Poppins | JetBrains Mono | Playful |
raleway |
Raleway | Fira Code | Sophisticated |
nunito |
Nunito | JetBrains Mono | Rounded |
work-sans |
Work Sans | Fira Code | Neutral |
default |
Helvetica | Courier New | System fallback |
All fonts are included in the fonts/ directory. Use --font-path fonts when compiling:
typst compile --root . --font-path fonts templates/invoice/default.typ output/invoice.pdf \
--input data=/path/to/invoice.jsonWhen using Claude or other AI assistants:
- Share the JSON schema from
cli/templates/so the AI knows the structure - Provide client context - the AI can look up client data from your database exports
- Review before compiling - always check the generated JSON for accuracy
- Use watch mode during iteration:
docgen watch documents/
Example prompt for Claude:
I'm using typst-business-templates. Here's my invoice schema: [paste schema]
Create an invoice JSON for client "Acme Corp" (K-001) for the following work:
- 40 hours frontend development at 95 EUR/hour
- Project: Website Redesign (P-001-02)
- Invoice date: today
- Payment terms: 14 days
- Project Overview - Current state and ideas
- Simplification Plan - Unix philosophy approach
- Roadmap - Detailed plan for upcoming improvements
This tool follows Unix philosophy:
- Do one thing well: Generate professional business documents
- Plain text: All data in human-readable JSON
- Composable: Integrate with scripts, AI tools, version control
- Simple: Direct CLI commands, no complex UI
Future improvements focus on simplicity, not feature bloat:
- Edit/delete clients and projects
- Document templates in more languages
- E-invoice support (ZUGFeRD/XRechnung)
- Better AI integration examples
MIT License - see LICENSE
Contributions welcome! Areas where help is needed:
- Additional document templates (delivery notes, credit notes, reminders)
- Internationalization (currently German-focused)
- Test coverage
- Binary releases for different platforms
Please feel free to submit a Pull Request.