Skip to content

Print flyer: open a real 5 × 7 in print dialogue - #22

Merged
DLinacre merged 1 commit into
mainfrom
arena/a01ba5fb-pokeguru
Nov 14, 2026
Merged

DLinacre merged 1 commit into
mainfrom
arena/a01ba5fb-pokeguru

Conversation

@DLinacre

Copy link
Copy Markdown
Owner

Follow-up to #21.

Problem

The Print flyer button opened the PDF with window.open(url, "_blank", "noopener"). Per spec (and in Chrome) a noopener window returns null, so the code always took its "pop-up blocked" branch and downloaded the PDF — the print dialogue never opened.

Fix

printFlyer() now builds the same vector scene as the PDF, writes it into a minimal print view and raises the browser's own print dialogue:

  • @page { size: 127mm 177.8mm; margin: 0 } — the dialogue opens at exactly 5 × 7 in, and the artwork stays vector (no bitmap, no resampling).
  • No scripts inside the print view; the hint line ("Print at 100% / Actual size") is hidden when printing.
  • If the pop-up is genuinely blocked, the PDF is downloaded instead, and the UI says so.

Verification

  • npx tsc --noEmit, npx eslint ., npm run build — clean.
  • npx vitest run — 151 passed; the new test asserts the print view contains the 5 × 7 in @page rule, the production host, inline SVG, and that print() is called once.

The print action now renders the same vector scene into a minimal print view
whose @page size is 127 x 177.8 mm and calls print(), so the dialogue opens
pre-sized and the output stays vector. Before this, the button opened the PDF
in a noopener tab (which returns null), so it always fell back to a download.
If the pop-up is blocked the PDF is downloaded instead.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@DLinacre
DLinacre merged commit 96f0e74 into main Nov 14, 2026
2 checks passed
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