Expand description
Typst for Laravel Rust: PDFs and images rendered in-process, without Chrome.
Templates are Typst files in resources/pdf. Each one reads the data it
is rendered with from data.cbor:
#let invoice = cbor("data.cbor")
Invoice #invoice.numberRegister TypstServiceProvider, then inject Typst and return what it renders:
use laravel::container::Inject;
use typst_laravel::{Pdf, Typst};
async fn show(typst: Inject<Typst>) -> laravel::Result<Pdf> {
typst.pdf("invoice", &serde_json::json!({ "number": "INV-7" })).await
}Structsยง
- A rendered PDF and its bytes. Returned from a handler, it opens in the browser.
- Png
- A rendered PNG and its bytes, which a handler may return as they are.
- Typst
- Renders Typst templates.
- Typst
Service Provider - Registers
Typstfor the templates inresources/pdf, and thetypst:templatecommand.