CopyCraft Spawns A4 Calligraphy Worksheets Locally Across Web and Desktop with One React Codebase
The project demonstrates how to ship a single React codebase as both a static web app and an Electron desktop app, and it records the practical gotchas of exporting pixel-perfect A4 pages, including html2canvas's SVG tiling bug and the decision to embed Word pages as full-page images for guaranteed layout fidelity. It also shows a minimal infrastructure approach: no backend, minimal analytics, and trial licensing with offline activation.
The tool covers 24 worksheet categories including name stroke order, Chinese characters, phrases, pinyin, poems, math drills, clock practice, and more, plus 45 ready-made templates organized by textbook sync, structural patterns, radicals, and other categories. Everything is generated locally: this is a static web app in the browser and an Electron shell on desktop, with a single React renderer driving preview, worksheet compilation, and export. That sharing avoids the classic 'preview looks different from the printout' problem.
Behind the scenes, A4 pages are laid out at 794x1123 CSS pixels (96dpi), with eight grid styles defined as 0-100 normalized geometry, rendered as SVG data URLs and tiled as backgrounds. Export captures each page at 2x resolution via html2canvas, then assembles PDFs with jsPDF or packs PNGs into Word documents as full-page images. A documented html2canvas bug makes SVG tiling unreliable, so the code temporarily replaces grid backgrounds with rasterized PNGs before capture. Stroke-order data comes from hanzi-writer-data with a three-CDN fallback, and pinyin-pro supplies tone-marked pinyin.
Deliberate trade-offs keep the app lean: no backend (so no cloud sync), Word exports are images rather than editable text (guaranteeing pixel-perfect layout), and only system fonts are used. Desktop builds include a 30-trials/14-day trial with offline activation based on HMAC-SHA256 and Crockford32 codes. Analytics are minimal: only print and export events are reported, with no worksheet content, names, or machine fingerprints. The codebase sits around 20k lines, 12k of them TypeScript, and is MIT-licensed.
A single React rendering layer powering preview, compilation, and export is a sound architectural choice that prevents drift between what users see and what gets printed.
Embedding full-page images in Word is a pragmatic trade-off for a print-oriented tool: visual fidelity matters more than text editability, and it eliminates layout-engine differences across platforms.
The 300ms debounced persistence is a classic performance trick that keeps the UI responsive when dragging sliders, since serializing the entire state tree on every change would block the main thread.
The decision to skip a backend entirely keeps privacy high and deployment cost at zero, but it also eliminates any possibility of cloud sync or collaboration, a trade-off the author explicitly accepts.