Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: PDF reports with Typst #5048

Open
pka opened this issue Jan 11, 2025 · 1 comment
Open

feature: PDF reports with Typst #5048

pka opened this issue Jan 11, 2025 · 1 comment
Assignees

Comments

@pka
Copy link

pka commented Jan 11, 2025

typst is already usable for PDF reports by calling the cli in a script, but it could be a great Windmill feature to have a built-in PDF reporting component. Since it's available as a Rust library with a compatible license, it would be a less heavy dependency than Puppeteer used for screenshot reports.

@pka
Copy link
Author

pka commented Feb 6, 2025

As a followup an excerpt from my post for creating a database report with typst:

DuckDB query with JSON output:

duckdb -json -c "SELECT * FROM read_parquet('s3://us-prd-motherduck-open-datasets/netflix/netflix_daily_top_10.parquet');" >data.json

Convert it to a PDF using Typst:

typst compile --input file=data.json --input title="Daily Top 10" jsontable.typ

and you get a 394 page PDF looking like this:

Image

Using this generic Typst template:

#import "@preview/tada:0.2.0"

// Page styling
#set page(
  paper: "a4",
  flipped: true
)
#set text(
  font: "IBM Plex Sans",
  size: 10pt
)

#let record-data = json(sys.inputs.at("file"))

// Table styling
#show table.cell.where(y: 0): set text(weight: "bold")
#set table(
  fill: (_, y) => if calc.even(y) { rgb("EAF2F5") }
)

#let td = tada.from-records(record-data)

= #sys.inputs.at("title", default: "Data Table")

#tada.to-table(td)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants