Why pdfops
- Built for agents. Every command returns one JSON document, errors say what to do next, and text can be read under a character budget with a resume point.
- Everything in one place. Reading, layout, tables, OCR, rendering, page surgery, stamping, redaction, forms, encryption and creation: 25 tools behind one schema.
- Nothing to set up. A single binary with no PDF libraries, no Python and no runtime. Only OCR needs an extra program, and pdfops can fetch the language data itself.
- Fast. Files open in milliseconds whatever their size, and page work runs on all cores. See the benchmarks.
- Redaction you can trust. Content is deleted from the page, not covered, and the result is checked by a second interpreter before anything is written.
Quick start
As an MCP server, with nothing installed beforehand:
For Claude Code: claude mcp add pdfops -- npx -y pdfops mcp.
Tools are named pdf_info, pdf_text, pdf_redact and so on, and take the same arguments as the
CLI. Relative paths resolve against the server's working directory.
Install
| Method | Command | Needs |
|---|---|---|
| npm | npm install -g pdfops or npx pdfops |
Node 18+ |
| Prebuilt, via cargo | cargo binstall pdfops |
cargo-binstall |
| From source | cargo install pdfops |
Rust 1.92+ |
| Manual | download an archive and put pdfops on your PATH |
nothing |
The npm package is a small launcher: on first run it downloads the binary for your platform from the GitHub release, checks it against the published SHA-256 sum and caches it. Prebuilt binaries cover Linux and macOS on x86-64 and ARM64, and Windows on x86-64.
OCR additionally needs the tesseract program; nothing else does. Language data is fetched on
request, without administrator rights:
Tools
| Command | What it does | |
|---|---|---|
| Read | info |
Page count, page size, metadata, encryption, outline and form summary |
text |
Text page by page, with a character budget and optional OCR fallback | |
search |
Find text or a regex, returns pages and snippets | |
layout |
Bounding box, font and size of every line or word | |
tables |
Tables as rows of cells, Markdown or CSV | |
outline |
Bookmarks with target pages | |
render |
Pages to PNG, to look at charts, scans and layout | |
images |
The images drawn on pages, as files | |
ocr |
Recognised text of scanned pages | |
| Build | create |
A new PDF from Markdown |
merge |
Several PDFs into one | |
pages |
Keep, reorder, duplicate or delete pages | |
split |
Split by page count or by ranges | |
| Edit | rotate |
Rotate pages by multiples of 90 degrees |
stamp |
Watermark, header, footer, page numbers, an image such as a signature, or a QR code | |
replace |
Replace text in place, in the document's own font where possible | |
redact |
Remove text, images and drawings in areas or matching text, then verify | |
set-meta |
Title, author, subject, keywords, creator | |
compress |
Shrink: lossless by default, optionally re-encoding and downscaling images | |
| Forms | forms |
Fields with their types, values and options |
fill |
Fill fields by name | |
| Protect | encrypt |
AES-256 passwords and permissions |
decrypt |
Remove password protection | |
| Setup | ocr-langs |
Whether tesseract is installed and which languages are usable |
ocr-install |
Download OCR language data, optionally install tesseract |
Run pdfops <command> --help for the options of each.
Examples
}
}
}
}
}
Reading:
Building and page work:
Editing:
Forms and protection:
Conventions
- Output. Every command prints one JSON document on stdout. Errors go to stderr as
{"error": "..."}with exit status 1. Add--prettyto indent. - Writing. Commands that write take
-o. It may be the input file: output goes through a temporary file. - Pages are 1-based and comma separated:
3,2-5,7-(to the end),-4(from the start),5-2(descending),last,odd,even,all. - Positions are in points with the origin at the top-left corner of the page as displayed, y
growing downwards.
layoutreports them,stamp --x/--yandredact --rectaccept them, and a pixel ofrender --dpi 72is exactly one point.
How it compares
| pdfops | PyMuPDF | pypdf | pdfplumber | qpdf | poppler-utils | |
|---|---|---|---|---|---|---|
| Text extraction | ✓ | ✓ | ✓ | ✓ | – | ✓ |
| Word positions and fonts | ✓ | ✓ | – | ✓ | – | positions |
| Tables | ✓ | ✓ | – | ✓ | – | – |
| Render pages | ✓ | ✓ | – | ✓ | – | ✓ |
| OCR | ✓ | ✓ | – | – | – | – |
| Merge, split, reorder, rotate | ✓ | ✓ | ✓ | – | ✓ | partly |
| Text, image and QR stamps | ✓ | ✓ | by overlay | – | by overlay | – |
| Redaction that removes content | ✓ | ✓ | – | – | – | – |
| Redaction verified before writing | ✓ | – | – | – | – | – |
| Replace text in place | ✓ | – | – | – | – | – |
| Fill forms | ✓ | ✓ | ✓ | – | – | – |
| Encrypt and decrypt | ✓ | ✓ | ✓ | – | ✓ | – |
| Create from Markdown | ✓ | from HTML | – | – | – | – |
| Built-in MCP server and tool schemas | ✓ | – | – | – | – | – |
| JSON from every command | ✓ | library | library | library | partly | – |
| Runtime needed | none | Python | Python | Python | none | none |
| License | MIT | AGPL or commercial | BSD | MIT | Apache-2.0 | GPL |
PyMuPDF is the closest in scope and is an excellent library; it is written in C, needs Python, and its AGPL license matters if you ship it. pdfops trades some breadth for a single MIT-licensed binary whose tools an agent can call directly.
Benchmarks
Best of 3 whole-process runs, start-up included, since that is what one tool call costs an agent.
Document: a 357 page, 1.4 MB manual; images on a 4.6 MB manual with pictures; forms on a one page
form. Machine: 4 core Intel i5-4460. Versions: poppler 26.08, qpdf 12.4, PyMuPDF 1.28, pypdf 6.19,
pdfplumber 0.11, tesseract 5.5. The fastest entry of each row is bold.
| Task | pdfops | command line tool | PyMuPDF | pypdf | pdfplumber |
|---|---|---|---|---|---|
info |
5 ms | pdfinfo 13 ms |
211 ms | 454 ms | 371 ms |
text, all pages |
483 ms | pdftotext 541 ms |
641 ms | 4146 ms | 34.5 s |
search, all pages |
430 ms | - | 627 ms | - | - |
layout, every word with its box |
548 ms | - | 758 ms | - | 33.0 s |
tables, 50 pages |
52 ms | - | 4422 ms | - | 4133 ms |
outline |
20 ms | - | 201 ms | 353 ms | - |
render, 20 pages at 150 dpi |
195 ms | pdftoppm 5962 ms |
1229 ms | - | - |
ocr, one page (render, then tesseract) |
2338 ms | tesseract 1511 ms |
- | - | - |
images, all embedded images |
391 ms | pdfimages 3897 ms |
675 ms | 5232 ms | - |
create, 100 sections of Markdown |
10 ms | - | - | - | - |
merge, three copies |
123 ms | qpdf 254 ms |
1183 ms | 3825 ms | - |
pages, keep 10 |
21 ms | qpdf 122 ms |
204 ms | 419 ms | - |
split, one file per page |
54 ms | pdfseparate over 60 s |
877 ms | 2492 ms | - |
rotate, all pages |
47 ms | qpdf 152 ms |
252 ms | 1309 ms | - |
stamp, text on every page |
33 ms | - | 610 ms | - | - |
stamp, QR code on every page |
180 ms | - | - | - | - |
redact, a word on every page |
2144 ms | - | 1532 ms | - | - |
replace, a word on every page |
1736 ms | - | - | - | - |
set-meta |
60 ms | - | 269 ms | 1416 ms | - |
compress |
65 ms | qpdf 274 ms |
1109 ms | - | - |
encrypt, AES-256 |
49 ms | qpdf 160 ms |
253 ms | 1715 ms | - |
decrypt |
76 ms | qpdf 178 ms |
397 ms | 2418 ms | - |
forms, list fields |
15 ms | - | 391 ms | 236 ms | - |
fill, one field |
7 ms | - | 509 ms | 433 ms | - |
Reproduce with scripts/bench.py on any document.
Why it is fast: info, layout, tables, render, images and ocr read objects on demand, so
opening a file costs a few milliseconds whatever its size. Text extraction, layout, tables,
rendering, splitting, image export and OCR run on all cores. Page operations copy only the objects
the selected pages reach, so output size and time follow the selection, not the source.
Using it without MCP
pdfops tools prints [{"name", "description", "inputSchema"}] for every command. Pass these to
any function calling API, then run the call through the CLI or the library.
let result = call?;
Typed entry points live in pdfops::ops, for example pdfops::ops::read::text(TextArgs { .. }).
Behaviour worth knowing
- Text outside Latin-1.
stamp,fill,replaceandcreateembed a subset of a font that has the glyphs: the one given withstamp --font, otherwise one found on the system. Latin-1 text uses the built-in Helvetica and embeds nothing. Text is placed glyph by glyph: scripts that need shaping or right-to-left layout (Arabic, Hebrew, Indic) will not come out right. - Redaction deletes what is under the areas from the page content: glyphs, image pixels (including scanned pages), drawings lying wholly inside an area, and annotations with the form values they show. Text around it does not move. The result is read back by a second, independent interpreter, and nothing is written unless every area is empty. When a page is built in a way that cannot be rewritten with certainty (inline images, JPEG 2000 or CMYK JPEG under an area), the command fails instead of guessing. It does not rewrite document metadata, bookmarks or attached files, and it removes the accessibility structure tree, which can repeat page text.
- Replace writes the new text with the codes the document's own font already uses for those
characters on that page, so style is kept exactly. If the font (usually a subset) lacks a needed
glyph, another font writes just those words, at the same size, position and colour, and the result
says so. Lines are not re-flowed: a longer replacement runs into what follows, and
overflow_ptreports by how much. Text inside form fields and annotations is not edited. - Tables drawn with ruling lines are read cell by cell and are reliable. Tables without lines
are inferred from column alignment (
detected_by: alignment) and deserve a look before trusting. - Create understands headings, emphasis, links, nested lists, quotes, code blocks, tables, rules and local images. HTML inside the Markdown is ignored; there is no HTML or CSS engine.
- Bookmarks.
merge,pagesandsplitkeep the bookmarks whose target page is in the output. They land at the top of that page. Named destinations used by links are not carried over. - Forms when merging. Fields of the second and later inputs are renamed
doc2.<name>,doc3.<name>, so equal names do not share a value. - Lossy compression is opt-in through
--image-qualityand--max-image-edge. It re-encodes 8-bit grey and RGB images as JPEG. Masks, palette images, CMYK and 1-bit scans are left untouched, and the output is never larger than the input. - Images are the ones a page actually draws, including inline images and images inside forms. JPEG and JPEG 2000 are written as stored; everything else (Flate, LZW, CCITT fax, JBIG2, palette, masks) is decoded to PNG.
- OCR quality and languages are tesseract's. Recognised text is returned, not written into the
PDF. When a language is missing, the error names the
ocr-installcall that fixes it, so an agent can recover on its own. Data comes from thetessdata_fastrepository (--bestfor the larger models) and is kept in~/.local/share/pdfops/tessdata, orPDFOPS_TESSDATAif set. Installing tesseract itself uses the system package manager; where that needs a password, the command to run is returned instead. - Signatures. Any change to a signed PDF invalidates its digital signatures.
Development
Built on lopdf (object model), pdf-extract (text), hayro (rendering, positions and image decoding), subsetter (font embedding) and pulldown-cmark (Markdown).
License
MIT