# Plan: Seiten drehen
## Goal
Add a new tool **"Seiten drehen"** (`/tools/rotate`) that fixes page orientation — the classic
case being scanned court mail with individual pages rotated 90°/180°. Users rotate pages
individually or all at once; the result is saved via the standard PDF `/Rotate` mechanism, so the
operation is **lossless and instant** (no rasterization, no re-encoding).
No new dependencies.
---
## Open decisions (defaults marked ✅)
### D1 — How rotation is applied
- ✅ **A. pdf-lib `setRotation` (document-level `/Rotate`).** `page.setRotation(degrees(angle))`
writes the page's rotation entry; every viewer honors it. Lossless, fast, file size unchanged.
Existing rotation of a page (from scanners that already set `/Rotate`) is read via
`page.getRotation().angle` and added to, so the user's delta is always applied on top of the
current state.
- B. Rasterize-and-rotate pixels. Unnecessary quality loss and memory cost; rejected.
### D2 — Grid capabilities
- ✅ **Extend `PdfPageGrid` with an optional action snippet.** The current grid renders fixed
cards. Add an optional snippet prop (e.g. `pageActions`) rendered below each thumbnail; existing
call sites (separate, watermark, extract) pass nothing and look unchanged. The rotate page uses
it for per-page rotate buttons and a rotation badge.
- B. Fork the grid inside the rotate page. Rejected: duplicates the accessible grid work.
---
## UX
- Route `/tools/rotate`, new `src/lib/tools.ts` entry:
`{ slug: 'rotate', title: 'Seiten drehen', description: 'Drehen Sie einzelne oder alle Seiten eines PDFs.', icon: 'rotate-cw' }`
- icon map entry.
- After load (`loadPdfDocument` + thumbnails like separate):
- Quick-action bar: **"Alle 90° rechts"**, **"Alle 90° links"**, **"Alle 180°"**,
**"Zurücksetzen"** (clears all deltas).
- Page grid: each card shows the thumbnail with a CSS rotation preview
(`transform: rotate({total}deg)` on the ``, contained in a square-ish frame so rotated
pages still fit), a small badge when the total rotation is non-zero (e.g. "90°"), and two
icon buttons (rotate left / rotate right) provided through the new `pageActions` snippet.
Buttons are real `