Skip to content

feat: Typst-based time report PDF generation#209

Open
madisvain wants to merge 4 commits intomainfrom
feature/typst-time-report-pdf
Open

feat: Typst-based time report PDF generation#209
madisvain wants to merge 4 commits intomainfrom
feature/typst-time-report-pdf

Conversation

@madisvain
Copy link
Copy Markdown
Member

Summary

  • Replaces the frontend @react-pdf/renderer approach (from Added minimal Time Report pdf component #207) with Typst as a Tauri sidecar binary for PDF generation
  • Adds a generate_time_report_pdf Tauri command that compiles a Typst template into a PDF with the time report data
  • Bundles Montserrat fonts and the Typst template as Tauri resources

Why Typst?

  • Better fit for a Rust/Tauri project — Typst is a Rust-based typesetting system, keeping PDF logic on the backend
  • Configurable templates — Typst templates are plain text files that users or developers can customize without touching application code
  • Extensible — this same approach can be expanded to invoice PDFs and other document types, with user-selectable templates
  • Cleaner separation — the frontend only sends data, the backend handles all rendering

Architecture

  1. Typst sidecar binary — bundled via tauri.conf.json externalBin (excluded from git, downloaded per-platform)
  2. Templatesrc-tauri/resources/templates/time-report.typ reads JSON data via sys.inputs
  3. Fonts — Montserrat font files bundled in src-tauri/resources/fonts/
  4. Backend commandgenerate_time_report_pdf in commands.rs serializes data to temp JSON, invokes Typst, returns result
  5. Frontend — Export button calls invoke("generate_time_report_pdf") with report data and file path from save dialog

Changes

  • src-tauri/Cargo.toml — added tauri-plugin-shell
  • src-tauri/tauri.conf.json — added externalBin, resources, shell-capability
  • src-tauri/capabilities/shell.json — sidecar permissions
  • src-tauri/src/lib.rs — registered shell plugin and command
  • src-tauri/src/commands.rsgenerate_time_report_pdf command
  • src-tauri/resources/templates/time-report.typ — Typst template
  • src-tauri/resources/fonts/ — Montserrat Regular, Medium, SemiBold
  • src/routes/time-tracking/reports.tsx — uses invoke() instead of disabled button

Setup

Contributors need to download the Typst binary for their platform:

# Example for macOS ARM
curl -L https://github.com/typst/typst/releases/download/v0.14.2/typst-aarch64-apple-darwin.tar.xz | tar xJ
mv typst-aarch64-apple-darwin/typst src-tauri/binaries/typst-aarch64-apple-darwin

Test plan

  • Download Typst binary for your platform into src-tauri/binaries/
  • cargo check in src-tauri/ compiles successfully
  • pnpm lint passes
  • Run app, navigate to Time Tracking > Reports, click Export
  • Verify PDF is generated with correct layout (title, date range, client, table)

Supersedes #207

🤖 Generated with Claude Code

madisvain and others added 4 commits February 9, 2026 17:37
Set up infrastructure for Typst-based PDF generation as a Tauri sidecar
binary. Adds shell plugin, capability permissions, externalBin and
resource bundling config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Typst template renders a time report PDF with date range, optional client
name, and a table of grouped time entries. Bundles Montserrat font files
as Tauri resources.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backend command that serializes report data to a temp JSON file, invokes
the Typst sidecar to compile the template into a PDF, and cleans up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the disabled Export button with a working handler that invokes
the generate_time_report_pdf Tauri command via the Typst sidecar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant