Skip to content

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

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

danmolitor wants to merge 5 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

danmolitor and others added 3 commits October 7, 2026 11:01
…plate

# Conflicts:
#	pnpm-lock.yaml
#	templates.json
Moves the template from 0.20.1 to the current release, and aligns
wrangler with the rest of the repo (4.136.1). Lockfiles, the
templates.json hash and worker-configuration.d.ts regenerated with the
repo's tooling. The pnpm lockfile also drops entries nothing referenced
(left over from the Containers starter change), which pnpm prunes when
an importer changes.

syncpack, templates lint, the npm lockfile check and prettier pass; the
template's 10 workerd tests pass; a wrangler dev render was verified
against the pinned version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the template's importer for @formepdf/html 0.28.0 and wrangler
4.136.1, and prunes entries nothing referenced. pnpm install
--frozen-lockfile passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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