# oyp cookbook -- your pdf chore, one line

for an agent about to `pip install` a pdf library, regex raw pdf bytes, or
start chrome to count pages. `oyp` is offline, opens no window, prints one
json object and exits with a code you can branch on. it is a real pdf reader
(xref streams, object streams, damaged tables, owner-locked files), not a
regex. if your own code already does the job, keep it.

cold-start benchmarks, exit codes, and install notes: [cli.html](cli.html).

```sh
oyp version            # is it here? {"ok":true,"version":...,"engine":true,...}
oyp help               # every verb; oyp help <verb> for its options
```

not found? `~/.local/bin/oyp` (linux / mac) or
`%LOCALAPPDATA%\Programs\oyp\current\oyp.exe` (windows); install from a
source checkout with `tools/install-cli.sh` / `tools/install-cli.ps1`.
full contract: [agents.md](agents.md) (it ships beside the binary too).

## the menu

| you want to... | one line |
|---|---|
| know what a pdf IS (pages, sizes, fonts embedded?, images, layers, signatures, viewports) | `oyp info set.pdf` |
| ...and catch blank pages | `oyp info set.pdf --ink` |
| check a pdf you just generated before you hand it to a human | `oyp verify out.pdf --pages 12 --size 17x11 --any-orientation` |
| fail the build when chrome shrank your print into a corner | `oyp verify out.pdf --fills-page 0.9` (0.12.7+ reads chrome's own print scale) |
| fail when a page came out blank (failed capture, empty print) | `oyp verify out.pdf --min-ink 0.001` |
| prove a marker / footer is on every page | `oyp verify pkg.pdf --text "ISSUED FOR CONSTRUCTION" --text-every-page` |
| prove sheet S-3 is on page 4 (not just in the index) | `oyp verify set.pdf --text-on "4:S-3" --text-word` |
| make sure a stale string is gone | `oyp verify rfq.pdf --no-text "site TBD"` |
| check the plotter won't substitute fonts | `oyp verify set.pdf --fonts-embedded` |
| check monochrome plain-document style (black on thin rules) | `oyp verify memo.pdf --plain` |
| keep your pipeline's own "fail" code | `oyp verify ... --fail-exit 2` |
| get the text, with positions | `oyp text doc.pdf --mode words` (or `lines`, `chars`, `plain`) |
| scrape a simple table | `oyp text doc.pdf --mode rows` (cells at wide gaps; a heuristic) |
| LOOK at a page (you're multimodal, use it) | `oyp render sheet.pdf --page 2 --dpi 100 --out p2.png` |
| render every page | `oyp render scan.pdf --pages all --dpi 150 --out page-{page}.png` |
| measure on a drawing, at the drawing's own scale | `oyp measure plan.pdf --page 1 --points "144,144 360,144"` |
| area + perimeter | `oyp measure plan.pdf --points "100,100 300,100 300,200" --closed` |
| snap to the drawing's exact gridline crossing | `oyp snap plan.pdf --at 382,401 --kinds int` |
| read existing markups (revu's, ours, anyone's) | `oyp annots marked.pdf` |
| add revu-compatible markups (cloud, callout, dimension, area...) | `oyp add-markups plan.pdf --spec markups.json --out review.pdf` |
| make each detail measure at its own scale in revu | `oyp add-viewports sheet.pdf --spec viewports.json --in-place` |
| make print dialogs default to actual size | `oyp set-print-scaling shop.pdf --value none --in-place` |
| stamp a build id / page x of y as real text | `oyp stamp pkg.pdf --text "REV-A p{page}/{pages}" --at bottom-right --out stamped.pdf` |
| staple pdfs, with bookmarks | `oyp merge --out book.pdf --bookmarks cover.pdf sheets.pdf:2-9` |
| pull some pages out | `oyp extract set.pdf --pages 4-6 --out details.pdf` |
| one file per page | `oyp split set.pdf --out-dir parts` |
| fix a sideways scan | `oyp rotate scan.pdf --pages 2 --by 90 --in-place` |
| a vendor pdf that wants a password | `oyp info spec.pdf --password-file pw.txt` (any verb; the password lives in the file, never in argv) |

every write verb leaves the input alone unless you say `--in-place`, and
even then it APPENDS a revision: the original bytes stay a byte-identical
prefix, signatures keep verifying, nothing someone else wrote gets
re-serialized. every file it writes is read back by two readers before it
lands. exit codes: 0 ok, 2 usage, 3 not found, 4 password, 5 no engine,
6 not a pdf, 7 a verify check failed.

## three ways in

```sh
oyp verify out.pdf --pages 12        # shell: read stdout json, branch on $?
```

```python
import oyp                           # clients/python/oyp.py, one stdlib file
oyp.run("verify", "out.pdf", pages=12, fills_page=0.9)   # raises oyp.OypError on a failed check
```

```sh
claude mcp add oyp -- ~/.local/bin/oyp mcp     # one tool per verb; render returns the png as an image
```

## what it will NOT do

- html -> pdf: chrome / playwright stay. (then `oyp verify` the result.)
- ocr of scanned pages: `text` on a scan returns nothing, honestly.
- printing to a device, real table reconstruction, qr decoding.
- intel macs natively: osx-x64 has only run under rosetta. apple-silicon
  macs and linux arm64 run every verb on real hardware on every push. if
  you're the first on an intel mac, let us know at support@ownyourpdf.com.

## feedback & requests

if `oyp` is close to what your pipeline needs, email
[support@ownyourpdf.com](mailto:support@ownyourpdf.com) with the job in one
line.
