PolyPDF

Palimpsest documentation

Command-line reference

The native Rust CLI uses the same local document engine as the desktop. Commands print JSON and accept an explicit library directory.

Identify a source

Document IDs are local integers. Revision and original artifact identifiers are SHA-256 digests. UI and CLI page numbers start at 1. Named revisions in comparison commands use main, branch:NAME, checkpoint:NAME or a full revision ID.

polypdf --library data import field-notes.pdf
polypdf --library data list
polypdf --library data show 1
polypdf --library data navigation 1
polypdf --library data inspect 1 --page 1

Read, organize and export

CommandBehavior
render DOC PAGE OUT.pngRender a page to a new PNG. Use --pixels to choose the longest edge.
extract DOC PAGEReturn embedded words with page, revision and bounding boxes. Add --html to write a reflowable page.
edit DOC move FROM TOMove one page and create a revision.
edit DOC select 3,1,1Build a new page sequence, including repeated positions.
edit DOC merge OTHERAppend another document’s page sequence.
export DOC OUT.pdfValidate and write a separate PDF. Choose an unused filename.

For scripts, pass the revision you observed with edit DOC --expected REVISION. A concurrent change produces a conflict before the edit can advance the branch.

Search, OCR and citations

polypdf --library data ocr 1 1 --language eng
polypdf --library data find-passages "river depth" --docs 1,2 --mode phrase
polypdf --library data index-library --all --page-budget 128
polypdf --library data resolve-citation 1 "$citation"

--page-budget 0 searches an existing index. Coverage counts distinct source pages in the selected documents. Embedded text can share index storage by content while results and OCR evidence remain scoped to their documents. OCR configuration and source geometry form part of a recognized passage’s identity.

Datasets and assertions

polypdf --library data dataset 1 grid.json --csv observations.csv
polypdf --library data report 1 grid.json checks.json rainfall.html
polypdf --library data report 1 grid.json checks.json rainfall.json --format bundle
polypdf replay-evidence rainfall.json

A grid binds rows, columns, units and a source method to a revision. Report checks support count, sum and mean. Report commands use exit status 0 for pass, 2 for fail and 3 for unknown. Operational errors also return a nonzero status. The output retains the check verdict and the evidence used.

What happens under the hood

SQLite tracks documents, immutable revisions, branches, OCR runs and an FTS5 passage index. Source PDFs live in content-addressed blobs. Updating the main head updates its searchable page membership in the same transaction. An optimistic head check protects competing edits.

PDF inspection, text extraction and rendering use restricted Linux workers. Workers receive explicit inputs, resource limits and network access blocked by seccomp. Locally installed Tesseract models provide recognition. Interactive document actions and embedded scripts are passive in the reader.

Embedded word bounds are normalized to the crop box, with origin at the top left. Source bounds include the PDF’s intrinsic rotation. View bounds also include rotations added during editing. OCR evidence retains its own configuration and score scale.

Measured search behavior

Warm phrase queryMatching filesp95
One station ID141 ms
Common field phrase10,000139 ms
Absent term035 ms

The sample library held 10,000 distinct one-page synthetic PDFs. Tests used a single open Rust engine connection, a warm OS cache, a zero indexing budget and a 30-result limit. Each workload used 50 timed samples after one warm-up. These figures describe local full-text retrieval on the tested 32-vCPU Linux VM. OCR latency and page rendering use different paths.