# PDF DECK

**Free PDF tools. No uploads, ever.** Merge, split, compress, rotate, crop, watermark, sign, redact, and more — every operation runs entirely in your browser. A file never touches a server, because there isn't one.

**Live site:** https://pdf.rk-portfolio.org

## Why this exists

iLovePDF and friends gate basic PDF operations behind a subscription and upload your files to their servers to do it. This does the same job, for free, without the upload — [`pdf-lib`](https://pdf-lib.js.org/) and [`pdf.js`](https://mozilla.github.io/pdf.js/) do the real work, both running client-side.

## Tools

- **Merge** — combine multiple PDFs, drag to reorder first.
- **Split** — by page ranges (`1-3,4,7-9`) or every N pages; multi-file output zips automatically.
- **Reorder / remove / extract** — thumbnail grid, drag to reorder, click to mark pages, save/remove/extract.
- **Rotate** — per-page or whole-document, 90° increments.
- **Crop** — drag a crop box on the first page, applies to every page.
- **Watermark** — text, adjustable opacity/rotation/size, tiled or centered.
- **Page numbers** — position, starting number, a few formats.
- **Sign** — draw a signature, click to place it, flattened into the page. Visual signature only, not a cryptographic e-signature.
- **Redact** — draw boxes over anything sensitive. On export, any page with a redaction is **rasterized** (rendered to an image), so the underlying text is genuinely destroyed — not just painted over.
- **Image → PDF** — one or many JPG/PNG into a single PDF; also covers scan-to-PDF via a phone camera.
- **PDF → Image** — export every page as PNG or JPG, zipped.
- **Compress** — rasterizes each page to a JPEG at your chosen quality and rebuilds the PDF. Shrinks file size reliably (especially on scanned/image-heavy PDFs) at the cost of making text non-selectable — a true stream-level recompressor needs deeper PDF internals than a client-side library exposes cleanly.
- **Compare** — extracts text from two PDFs and shows a line-level diff.

## Known gaps

Not included, on purpose, because they need something more than a browser can do alone:

- **Word / Excel / PowerPoint ↔ PDF** — needs a real document-rendering engine (e.g. LibreOffice headless), which means a backend. Not free-to-run the way the rest of this is.
- **OCR** — [Tesseract.js](https://tesseract.projectnaptha.com/) could do this client-side (WASM), but ships a large model download and is slow on big files. Deferred.
- **Protect / Unlock (password encryption)** — real PDF encryption (RC4/AES per spec) isn't something `pdf-lib` implements, and hand-rolling PDF crypto is a security-sensitive undertaking that deserves its own careful pass, not a rushed add-on.

## Run locally

```bash
python3 -m http.server 8000
# open http://localhost:8000
```

## Tests

Open [`/?selftest`](https://pdf.rk-portfolio.org/?selftest) — runs the pure page-math functions (range parsing, chunking, diffing) plus a real merge → save → reload → rotate round-trip through `pdf-lib`, and asserts the output is a valid PDF at every step. Tab title reads `SELFTEST PASS n/n`.

## Tech

Plain HTML/CSS/JS, no build step, no framework. `pdf-lib` and `pdf.js` from CDN. The dependency-free zip writer is shared with [devops-tools](https://github.com/RadhaKrishna0018/devops-tools)'s Helm builder.
