feat: add print/PDF export for character sheets and campaign party#77
feat: add print/PDF export for character sheets and campaign party#77lionel-lints wants to merge 1 commit into
Conversation
Adds browser-native print-to-PDF export: - GET /characters/:id/print — standalone multi-column character sheet (owner + DM) - GET /campaigns/:id/print — DM-only full party export with cover page The print layout uses a two-column grid (abilities/skills left, combat/HP/weapons/items right) with a second page for traits and spells. Zero new runtime dependencies — uses the browser's built-in print dialog. Also fixes a Bun.sql 1.3.1 bug where a PostgreSQL connection URL was silently ignored in favor of the default 'postgres' database; switching to the options object form resolves the issue. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
i haven't been able to reproduce this -- any additional information about it? |
|
Closing in favor of #78, which takes a different approach — generating PDFs server-side by filling MPMB's official D&D character record sheet template rather than rendering HTML and relying on the browser's print dialog. The HTML approach had hard layout issues in print mode (forced page breaks with whitespace, two-column grid not balancing) and created a parallel design system to maintain. Thanks for the original work, @lionel-lints — your PR was the inspiration for #78. Your commit is preserved as the first commit on the new branch for credit. |
Summary
GET /characters/:id/print— a standalone, print-optimized character sheet accessible to both the character owner and any DM of a campaign containing the characterGET /campaigns/:id/print— a DM-only route that prints all party characters back-to-back with a cover page listing the partyHow it works
Uses the browser's built-in print dialog (Ctrl+P → Save as PDF) — zero new runtime dependencies. The print route returns a standalone
<html>document viac.html(), bypassing the app's jsxRenderer layout. It auto-triggerswindow.print()on load.The character sheet uses a two-column grid layout:
The visual style extends the app's existing aesthetic — clean bordered boxes, minimal typography — translated to print-optimized CSS with
@page { size: letter portrait; margin: 0.5in; }. A screen preview mode wraps the sheet in a gray background so it looks like a real page at 8.5in width.Bug fix: Bun.sql database URL parsing
Fixes a bug in
src/db.tswhereBun.sql1.3.1 silently ignores the database name in a PostgreSQL connection URL, connecting to the defaultpostgresdatabase instead ofcsheet_dev. Switched from the URL string form to the options object form (new SQL({ hostname, port, username, password, database })).Test plan
window.print()fires automatically/campaigns/:id/print(redirected)mise run test src/routes/character.test.ts— 44 tests passmise run test src/routes/campaigns.test.ts— 115 tests pass🤖 Generated with Claude Code