Print cards at true size and edge to edge - #27
Merged
Merged
Conversation
Cards are drawn at 63 x 88mm — the finished size of a Magic: the Gathering card — but the sheet always declared @page size: A4. Printing that on US Letter makes the browser scale the whole sheet by 279.4/297, so the cards come out 59 x 83mm. Pick the paper in the print toolbar instead (guessed from the browser locale, then remembered) and emit the matching @page rule, so the sheet is never scaled. Cards now abut with no gutter and square corners, so one straight cut separates two of them instead of leaving a strip of waste. That also shrinks the block to 189 x 264mm, which is what lets three 88mm rows fit Letter's 279.4mm sheet at all — the old 2mm row gaps needed 268mm. The toolbar states the card size and that the sheet must print at 100% scale, since "fit to page" shrinks it just as the wrong paper does. Layout tests now assert the 189 x 264mm gutterless grid, and that each paper size produces its own PDF MediaBox with no extra sheets. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Deploying warmuster with
|
| Latest commit: |
c4f1e53
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7987a1ae.warmuster.pages.dev |
| Branch Preview URL: | https://codex-card-print-size.warmuster.pages.dev |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Abutting cards share a cut line, which is the fastest way to cut a sheet but leaves no margin for a blade that wanders. "Card gap" opens a gutter between them instead, so each card gets its own edge. The gutter is clamped to what the chosen paper can still fit 3 x 3 cards in: A4 has 8.5mm of vertical slack to spend and allows 4.5mm, Letter has 1.7mm and allows 1.5mm. Switching paper re-clamps the stored value, so moving an A4 gutter to Letter can never push a row onto a fourth page. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The size problem
Cards are drawn at 63 × 88 mm — the finished size of a Magic: the Gathering card — and that part was already right. But the sheet always declared
@page { size: A4 }. Printing an A4 sheet on US Letter makes the browser scale it to fit the shorter paper:That 6% shrink is why the cards came out smaller than an MTG card. "Fit to page" scaling in the print dialog does the same thing.
Fix: a paper picker in the print toolbar (A4 / US Letter) that emits the matching
@pagerule, so the sheet is never scaled. It is guessed from the browser locale on first use and remembered afterwards. The toolbar also now states the card size and that the sheet needs 100% scale.Measured from a generated Letter PDF: MediaBox 612 × 792 pt (215.9 × 279.4 mm), card drawn at 238 × 333 px = 62.97 × 88.11 mm.
Cutting
Cards now abut by default, with square corners, so one straight cut separates two of them rather than leaving a strip of waste between them.
That also shrinks the 3 × 3 block from 197 × 268 mm to 189 × 264 mm, which is what makes three 88 mm rows fit Letter's 279.4 mm sheet at all — hence Letter's tighter 6 mm margins. A printer whose unprintable border exceeds ~7.7 mm cannot fit 3 × 3 at full size on Letter; that is a physical limit of the paper, not of the layout.
Card gap
A Card gap field in the toolbar opens a gutter for anyone who would rather give each card its own edge than share a cut line. It is clamped to what the chosen paper can still fit 3 × 3 cards in — A4 allows up to 4.5 mm, Letter only 1.5 mm — and switching paper re-clamps the stored value, so carrying an A4 gutter over to Letter can never push a row onto a fourth page.
Test plan
npm test— 267 passed, including new unit tests for the gutter maximum and clamping.npx playwright test— 8 passed, including three new tests:npm run buildclean.🤖 Generated with Claude Code