$npx -y skills add heymegabyte/claude-skills --skill 18-document-processingPDF/DOCX/XLSX/PPTX generation and parsing on Cloudflare Workers. Covers CF Browser Rendering → PDF, pdf-lib Worker-native generation, docx/exceljs output, pptxgenjs slides, and RAG-ready text extraction. Use cases: donor annual reports, SaaS invoices, tax receipts, financial repo
| 1 | # 18 — Document Processing |
| 2 | |
| 3 | Worker-native document I/O. All generation runs at the edge — no Lambda, no container, no third-party conversion SaaS. |
| 4 | |
| 5 | ## Sub-modules |
| 6 | |
| 7 | - `pdf-generation.md` — CF Browser Rendering → PDF + pdf-lib fallback |
| 8 | - `pdf-parsing.md` — text + table extraction for RAG ingestion |
| 9 | - `docx-xlsx.md` — DOCX (docx library) + XLSX (exceljs) generation in Workers |
| 10 | - `pptx-generation.md` — PPTX via pptxgenjs in Workers |
| 11 | |
| 12 | ## Decision tree |
| 13 | |
| 14 | ``` |
| 15 | Need document output? |
| 16 | ├── PDF (invoice / receipt / report) |
| 17 | │ ├── Complex layout (HTML → PDF) → CF Browser Rendering |
| 18 | │ └── Programmatic (no layout) → pdf-lib in Worker |
| 19 | ├── DOCX / XLSX (data export / mail merge) |
| 20 | │ ├── DOCX → docx library (pure JS, Worker-compat) |
| 21 | │ └── XLSX → exceljs (no canvas dep, Worker-compat) |
| 22 | └── PPTX (slide deck / pitch deck) |
| 23 | └── pptxgenjs (Worker-compat, no native deps) |
| 24 | |
| 25 | Need document input (RAG)? |
| 26 | ├── PDF text → pdf-parse (pure JS) or Workers AI document extraction |
| 27 | └── Tables → structured JSON → D1 or Vectorize |
| 28 | ``` |
| 29 | |
| 30 | ## Cloudflare primitives used |
| 31 | |
| 32 | - `CF Browser Rendering` — puppeteer-compatible Workers binding for HTML → PDF |
| 33 | - `R2` — store and serve generated documents |
| 34 | - `D1` — job state + document metadata |
| 35 | - `Workers AI` — optional OCR for scanned PDFs (Llama Vision) |
| 36 | - `Queues` — async generation jobs (large reports) |
| 37 | |
| 38 | ## Use case map |
| 39 | |
| 40 | | Use case | Format | Method | |
| 41 | |---|---|---| |
| 42 | | SaaS invoice | PDF | pdf-lib → R2 | |
| 43 | | Tax receipt (nonprofit) | PDF | CF Browser Rendering → R2 | |
| 44 | | Donor annual report | PDF | CF Browser Rendering (full layout) | |
| 45 | | Financial export | XLSX | exceljs → R2 | |
| 46 | | Grant application | DOCX | docx → R2 | |
| 47 | | Board slide deck | PPTX | pptxgenjs → R2 | |
| 48 | | RAG: donor docs | Text | pdf-parse → Vectorize | |
| 49 | |
| 50 | ## Cross-links |
| 51 | |
| 52 | - `rules/cloudflare-lock-in-is-leverage.md` — CF Browser Rendering over puppeteer SaaS |
| 53 | - `rules/feature-flags.md` — gate new doc types behind flag before GA |
| 54 | - `13-observability-and-growth/` — track document generation events in PostHog |
| 55 | - `08-deploy-and-runtime-verification/` — smoke-test R2 presigned URL after deploy |