document-processinglisted
Install: claude install-skill heymegabyte/claude-skills
# 18 — Document Processing
Worker-native document I/O. All generation runs at the edge — no Lambda, no container, no third-party conversion SaaS.
## Sub-modules
- `pdf-generation.md` — CF Browser Rendering → PDF + pdf-lib fallback
- `pdf-parsing.md` — text + table extraction for RAG ingestion
- `docx-xlsx.md` — DOCX (docx library) + XLSX (exceljs) generation in Workers
- `pptx-generation.md` — PPTX via pptxgenjs in Workers
## Decision tree
```
Need document output?
├── PDF (invoice / receipt / report)
│ ├── Complex layout (HTML → PDF) → CF Browser Rendering
│ └── Programmatic (no layout) → pdf-lib in Worker
├── DOCX / XLSX (data export / mail merge)
│ ├── DOCX → docx library (pure JS, Worker-compat)
│ └── XLSX → exceljs (no canvas dep, Worker-compat)
└── PPTX (slide deck / pitch deck)
└── pptxgenjs (Worker-compat, no native deps)
Need document input (RAG)?
├── PDF text → pdf-parse (pure JS) or Workers AI document extraction
└── Tables → structured JSON → D1 or Vectorize
```
## Cloudflare primitives used
- `CF Browser Rendering` — puppeteer-compatible Workers binding for HTML → PDF
- `R2` — store and serve generated documents
- `D1` — job state + document metadata
- `Workers AI` — optional OCR for scanned PDFs (Llama Vision)
- `Queues` — async generation jobs (large reports)
## Use case map
| Use case | Format | Method |
|---|---|---|
| SaaS invoice | PDF | pdf-lib → R2 |
| Tax receipt (nonprofit) | PDF | CF Browser Rendering → R2 |
| Donor annual report