pdf-operationslisted
Install: claude install-skill th3r-dev/th3-skills
# PDF operations in pdf-kit
All PDF manipulation here runs client-side with `pdf-lib` + `pdfjs-dist`. There is no
server-side merge/split — the worker (`worker/index.ts`) only proxies `compress` and `ocr`
to an external Stirling-PDF instance. Don't add a server endpoint for merge/split/rotate;
`pdf-lib` in the browser already does it, keeping the "processed locally" guarantee shown
in the UI.
## Merge multiple PDFs into one — already implemented, reuse it
This is not a missing feature. The existing workspace flow already merges any number of
PDFs (and images) into a single output:
1. `src/features/workspace/import-files.ts` (`importPdf` → `isolatePdfPages`) splits every
dropped PDF into one single-page `PDFDocument` per page, so each page becomes an
independent `WorkspacePage` with its own `source` blob and `pageIndex: 0`.
2. The pages array holds pages from every dropped file, in the order the user arranged
them (drag-and-drop reordering, rotate, delete — see `src/features/workspace/model.ts`).
3. `src/features/image-to-pdf/generate.ts` (`generatePdf`) walks that array and, for each
`kind: 'pdf'` page, `copyPages`s it into one output `PDFDocument`, then `output.save()`
returns the merged bytes.
So "merge PDF A + B into one file" == drop both files on the workspace and click
**Create PDF**. Covered by the test `merges imported PDF pages in workspace order` in
`tests/pdf-generation.test.ts`.
If you need a *headless* merge (no workspace/UI involved — e.g. a