Skip to main content

PageLedger: auditable OCR and document extraction runs

PageLedger: the tallied page

PyPI CI Python versions License DOI

PageLedger records document extraction one page at a time. It calls your chosen engine, tracks source files and adapter settings, checks budgets, and writes the text with its provenance and review queue. Runs are directories of JSON, YAML, Markdown, and raw output that you can inspect without a service or database.

It grew out of a Soviet census digitization project. The same records help archives, historians, and research teams trace an extracted page back to its source and reconstruct how it was produced.

Install

PageLedger 0.5.2 requires Python 3.10 or later:

pip install pageledger==0.5.2
pageledger --version

For PDFs, install "pageledger[pdf]==0.5.2". Scanned PDFs also need Poppler and Tesseract installed separately. pageledger doctor checks the available tools.

First run

The built-in text adapter needs no OCR engine or provider. This example creates two source pages; the replacement character on page 2 deliberately triggers a review warning.

printf 'first page\fsecond page with a replacement character �\n' > sample.txt
pageledger init-config --out pageledger.yml
pageledger run sample.txt --config pageledger.yml --out runs/first
pageledger inspect-run runs/first
sed -n '1,20p' runs/first/raw/doc_0001_page_0002.txt
sed -n '1,80p' runs/first/audit.md
pageledger verify-run runs/first

runs/first/ contains the extracted text, per-page provenance, quality signals, cost evidence, and an executable rerun plan. Unknown cost stays unknown. Verification checks the ledger's integrity; review the output against the source to judge transcription accuracy.

Rerun the flagged pages into a new directory and compare the results:

pageledger rerun runs/first --config pageledger.yml --out runs/second
pageledger compare-runs runs/first runs/second

This example uses the same adapter, so its output stays the same. Supply a stronger adapter config when needed. A rerun retains the parent linkage and source page numbers; you decide which outputs to use.

The text tutorial continues through CSV export, review notes, and bundle replay. For scans, follow the PDF/OCR tutorial.

Process a document

For a small offline example, follow the document-job tutorial. It covers processing, recovery, and review with a synthetic text file.

Document processing and resumable runs require a POSIX system such as macOS or Linux. Use process when you want one job to manage local text extraction, OCR for pages with defect evidence, and optional image-model attempts. The job retains every attempt and publishes a transcript with links to source pages and a report of unresolved work.

Create processing.yml:

schema_version: "0.1"
run:
  adapter: pdf_text
processing:
  local_ocr:
    adapter: pdf_ocr
    adapter_options:
      lang: eng
      dpi: 300
  limits:
    max_attempt_pages: 100
    max_image_pages: 0

With the PDF extra, Poppler, and Tesseract installed, sample a document:

pageledger process book.pdf --config processing.yml --pages "1-10" --out jobs/book
pageledger inspect-job jobs/book
pageledger verify-job jobs/book

Open jobs/book/transcript.md for the selected text and jobs/book/report.md for the source links, attempts, and review reasons. Image stages require an explicit adapter and a positive page limit. A completed job can still have pages awaiting human review; review-job records decisions bound to the source and selected output. See the document processing guide for configuration, budgets, and review receipts.

The 60-page validation report shows what these checks caught and where source review is still needed.

Recover interrupted work

Document jobs retain recovery evidence automatically. For an individual run, opt in when starting it:

pageledger run book.pdf --adapter pdf_ocr --resumable --out runs/book
# After an interruption:
pageledger resume runs/book

Use pageledger resume jobs/book for a document job. Keep the source files, output directory, and adapter environment in place. Resume verifies saved responses and reuses them without another extraction call. A request started without a saved outcome stops recovery because it may already have been processed. See the checkpoint specification for supported states and recovery limits.

What the ledger records

Record Use
Source hashes and page IDs Trace output to the original document and page, including samples and reruns.
Adapter, model, options, and prompt Identify how each page was extracted.
Page, token, time, and cost totals Check budgets and distinguish reported charges from configured estimates.
Quality signals and grades Find pages to inspect, with the evidence behind each warning. Grades are not accuracy scores.
Normalized records Align structured tables, JSON, or CSV to declared columns and arithmetic checks; retain failed checks and coercions.
Review and rerun queues Re-extract selected pages or hold them for human review.
Verified bundles and replay results Transport a completed generation-zero run and its source bytes; compare output under the recorded adapter identity.

Built-in adapters cover text files, PDF text layers, and Tesseract OCR. The adapter protocol supports other engines; the Docling example supplies local layout and VLM conversion. Core depends on PyYAML, with pypdf in the PDF extra.

classify produces a separate route map for review before run --routes. align can revise structured records without re-extracting. Bundle replay requires a locally available compatible adapter; whole document jobs and runs with image-input evidence cannot yet be bundled. The capabilities and limits describe these contracts in full.

Documentation

Start here Reference
Documentation index All guides and artifact specifications
Text tutorial · PDF/OCR tutorial Run, inspect, review, and rerun
Document processing Stages, shared budgets, reports, and human review
Checkpoint recovery Resume rules and uncertain requests
CLI and configuration Commands, flags, and settings
Run artifacts Files, identities, and verification
OCR options · Multilingual OCR Engines, languages, and historical documents
Scanned archive example Recorded OCR and escalation on a declassified document

Contributing

Testing a collection we haven't seen? Open a corpus report with the script, adapter, page count, and a redacted sample. New collections are how the quality signals improve. Development setup and guidelines are in CONTRIBUTING.md.

Citing

Software citation lives in CITATION.cff. PageLedger keeps software and source-data citations separate; dataset_citation in the config records the latter into every manifest.

MIT license.

Metadata

Release files for pageledger 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pageledger 0.5.2
File Size Uploaded
pageledger-0.5.2.tar.gz 354.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pageledger 0.5.2
File Interpreter ABI Platform
pageledger-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 520.6 kB

Release files / pageledger-0.5.2.tar.gz

Download URL pageledger-0.5.2.tar.gz
Size 354.0 kB
Tags Source
SHA-256 checksum
How to use checksums
55551a12e3ff1f1fb86ce3a43c95b81f3a20ff45b6efe1647b7788ab4efd72de
BLAKE2b-256 checksum
How to use checksums
25a43064923db1ed46f2a547064758a3bf4fd6f45ee62c66a47a00e1bc935d66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release files / pageledger-0.5.2-py3-none-any.whl

Download URL pageledger-0.5.2-py3-none-any.whl
Size 166.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa4c3c7847963cd851b5b5b7e7798b272949309752407c1ce3390c42dc7d7467
BLAKE2b-256 checksum
How to use checksums
58af0fdad12b1e9772b1022a1a886a9e0eaa4f37d2cb6b107d9dc6b5418bf9b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.0

2 release files

0.6.0

2 release files

This release

0.5.2 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page