Typst

Hex.pmDocs

Elixir bindings for the Typst typesetting system, powered by a Rust NIF. Generate PDFs, PNGs, and SVGs from Typst markup directly in your Elixir application.

Features

Installation

Add typst to your list of dependencies in mix.exs:

def deps do
  [
    {:typst, "~> 0.2"}
  ]
end

Usage

Basic rendering

{:ok, pdf} = Typst.render_to_pdf("= Hello World")

{:ok, [png]} = Typst.render_to_png("= Hello World")

{:ok, [svg]} = Typst.render_to_svg("= Hello World")

EEx templating

{:ok, pdf} = Typst.render_to_pdf(
  "= Report for <%= name %>\nDate: <%= date %>",
  name: "Acme Corp",
  date: "2026-03-07"
)

Tables

alias Typst.Format.Table
alias Typst.Format.Table.Header

table = %Table{
  columns: 3,
  content: [
    %Header{repeat: true, content: ["Name", "Qty", "Price"]},
    ["Widget", "10", "$5.00"],
    ["Gadget", "3", "$12.50"]
  ]
}

{:ok, pdf} = Typst.render_to_pdf("<%= table %>", table: table)

Virtual assets

logo = File.read!("logo.svg")

{:ok, pdf} = Typst.render_to_pdf(
  ~S|#image(read("logo", encoding: none), width: 6cm)|,
  [],
  assets: [logo: logo]
)

Options

All render functions accept these options:

Documentation

Full documentation is available at hexdocs.pm/typst.

Cutting a new release

License

Apache-2.0