Custom PDF layout (replace MPMB template)#80
Merged
Merged
Conversation
Replaces the MPMB template-fill PDF generator with a self-contained pdf-lib renderer. Layout is inspired by the 2024 WotC sheet (top identity strip with stat tiles, vertical ability column on the left with notched tabs and explicit save row, sectioned right column for Weapons / Skills / Spellcasting / Features / Equipment). Public API is unchanged: generateCharacterPdf(char, playerName?) and generateCampaignPdf(entries) keep the same signatures, so the /characters/:id/pdf and /campaigns/.../pdf routes need no changes. Tests in characterPdf.test.ts are rewritten at the behavior level — they assert that the PDF parses, has the expected page count, and contains the expected drawn text (via a helper that inflates each PDFRawStream and decodes the hex string literals). The assets/mpmb/*.pdf template files are no longer referenced by any code path but are left on disk for a separate history-rewrite task to remove. utils/sample-character-pdf.ts is a small dev helper that renders the first non-archived character in the dev DB to /tmp/csheet-sample.pdf for visual iteration on the layout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/services/characterPdf.ts(MPMB template fill) with a self-contained pdf-lib renderer. We can't redistribute MPMB's sheets, so we own the layout end-to-end.generateCharacterPdf(char, playerName?)andgenerateCampaignPdf(entries)keep the same signatures — no route changes needed.What it looks like
Page 1 (always):
Page 2+ (only if needed): Wild Shape block for druids; per-class spells with cantrip / prepared / spellbook sections.
Tests
characterPdf.test.tsrewritten at the behavior level: PDF parses, page count in range, drawn text appears in decoded content streams. The helper inflates each `PDFRawStream` and decodes PDF hex string literals (`<54657374> Tj`) so ASCII text matches work.MPMB assets
`assets/mpmb/*.pdf` is no longer referenced by any code path. Left on disk for the separate history-rewrite task.
Test plan