Skip to content

Add invoice-pdf-template: HTML-to-PDF invoices with R2 and KV - #1144

Open
danmolitor wants to merge 2 commits into
cloudflare:mainfrom
danmolitor:add-invoice-pdf-template
Open

Add invoice-pdf-template: HTML-to-PDF invoices with R2 and KV#1144
danmolitor wants to merge 2 commits into
cloudflare:mainfrom
danmolitor:add-invoice-pdf-template

Conversation

@danmolitor

Copy link
Copy Markdown

Description

Adds invoice-pdf-template: a Worker that renders invoice PDFs from HTML + print CSS using @formepdf/html (WASM in the isolate, no browser), stores them in R2, and indexes metadata in KV. Includes a form UI, a JSON API, and a vitest-pool-workers suite (10 tests, run in real workerd).

No linked issue - this is a new template contribution.

Lockfiles were generated with the repo's templates CLI; templates lint, lint-npm-lockfiles, syncpack, and prettier pass locally. The dependency is pinned to @formepdf/html@0.20.1.

Per CONTRIBUTING.md I've omitted preview_image_url, preview_icon_url, and publish - could a reviewer supply the image URLs? I have a 16:9 screenshot of the running template ready to attach.

Checklist

  • Template Metadata
    • template directory ends with -template
    • "cloudflare" section of package.json is populated
    • template preview image uploaded to Images (needs a maintainer — screenshot ready)
    • README is populated and uses <!-- dash-content-start --> and <!-- dash-content-end --> to designate the Dash readme preview
    • .gitignore file exists
    • package.json contains a deploy command
    • package.json contains private: true and no version field

danmolitor and others added 2 commits September 6, 2026 21:38
Renders invoice PDFs inside the Worker with @formepdf/html (Rust layout
engine compiled to WASM, web target, explicit init), stores the bytes in
R2, and indexes invoice metadata in KV so the list persists. Plain static
form UI served by Workers Assets; Hono routes for render, list, fetch and
delete.

Includes 10 vitest-pool-workers tests that exercise the real engine and
bindings in workerd, a Playwright smoke spec, and a README that states
the Workers Paid plan requirement (a render costs ~20 ms CPU, above the
Free plan's 10 ms cap) and the measured cold/warm numbers.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ELyDw6a7bYVMdsMtAdj4YJ
0.20.1 fixes the worker entry's result shape (the layout-pass count
declared in the package's types is now actually returned in workerd).
Lockfiles regenerated with the templates CLI; template tests pass in
workerd and a wrangler dev render was verified against the pinned
version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019eLgo72VYmQp3kNz9PZDHs
@danmolitor

Copy link
Copy Markdown
Author
invoice-pdf-template-screenshot

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