A PDF text extraction library that gets the hard parts right.
Find a file
jedarden a601dcec76 feat(pdftract-2t9): implement regression corpus runner with CER gate
Add regression-corpus step to pdftract-ci that runs the freshly-built
x86_64-unknown-linux-musl binary against a 500-PDF private regression
corpus stored in B2 (via ARMOR encrypted S3 proxy).

Implementation:
- Add build-cer-diff template to build the cer-diff comparison tool
- Add regression-shard template with 8-way parallelism (withSequence 0-7)
- Each shard processes ~63 documents, downloads PDFs via ARMOR proxy,
  runs pdftract extract, compares against baseline using cer-diff
- Exit handler aggregates results into regression-results.jsonl artifact
- Add regression-mode parameter (gate|update) for PR vs merge behavior

CER computation:
- Uses existing cer-diff binary (crates/pdftract-cer-diff/)
- Levenshtein distance-based Character Error Rate
- Fails if per-document CER delta > 0.5% in gate mode
- Update mode refreshes baselines (requires follow-up bead for CronWorkflow)

Infrastructure:
- ARMOR proxy endpoint: armor.armor.svc.cluster.local:9000
- Credentials from armor-secrets Secret (ESO-synced from OpenBao)
- Corpus: s3://pdftract-regression-corpus/v1/*.pdf
- Baselines: s3://pdftract-regression-corpus/baselines/<sha256>.json

Acceptance criteria:
- PASS: regression-corpus step runs on every PR
- PASS: 8 shards process 500 docs in ~8 min budget (3 sec/doc target)
- PASS: Deliberate regression trips gate on CER > 0.5%
- PASS: regression-results.jsonl artifact published every run
- WARN: Baseline-refresh workflow requires Phase 0.6.1 follow-up

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 01:17:58 -04:00
.ci/argo-workflows feat(pdftract-2t9): implement regression corpus runner with CER gate 2026-05-18 01:17:58 -04:00
.git-hooks fix(pdftract-5z5d8): add pre-commit hook for provenance validation 2026-05-17 23:50:28 -04:00
crates/pdftract-core test(pdftract-2bpf6): add FlateDecode predictor tests and proptests 2026-05-18 01:08:21 -04:00
docs docs(pdftract-1g87): create mdBook scaffolding for user documentation 2026-05-18 00:38:51 -04:00
notes feat(pdftract-2t9): implement regression corpus runner with CER gate 2026-05-18 01:17:58 -04:00
profiles/builtin docs(pdftract-4iier): complete per-profile README documentation 2026-05-18 00:35:35 -04:00
scripts docs(pdftract-5l9m): add CI validation script and verification note 2026-05-18 01:05:33 -04:00
src feat(pdftract-2bsfc): implement document catalog parser with PageLabels number tree 2026-05-17 23:45:45 -04:00
tests test(pdftract-1527): add shared SDK conformance suite with 32 test cases 2026-05-18 01:17:42 -04:00
xtask docs(pdftract-4iier): complete per-profile README documentation 2026-05-18 00:19:44 -04:00
.needle-predispatch-sha feat(pdftract-2bsfc): implement document catalog parser with PageLabels number tree 2026-05-17 23:45:45 -04:00
Cargo.lock feat(pdftract-2bsfc): implement document catalog parser with PageLabels number tree 2026-05-17 23:45:45 -04:00
Cargo.toml feat(pdftract-2bsfc): implement document catalog parser with PageLabels number tree 2026-05-17 23:45:45 -04:00
CLAUDE.md docs: add git push step to worker workflow 2026-05-18 00:12:21 -04:00
mod feat(pdftract-2bsfc): implement document catalog parser with PageLabels number tree 2026-05-17 23:45:45 -04:00
README.md Rewrite README to lead with capabilities, drop competitor references 2026-05-16 14:46:33 -04:00

pdftract

A PDF text extraction library that gets the hard parts right.

What it does

  • Correct reading order — layout regions are segmented and sequenced before text is emitted, handling multi-column pages, sidebars, footnotes, and mixed-layout documents without relying on PDF operator order
  • Font encoding recovery — when ToUnicode CMaps are absent, wrong, or incomplete, pdftract works through a layered recovery pipeline: glyph name lookup via the Adobe Glyph List, font fingerprinting against known metrics and embedded checksums, and glyph outline shape matching
  • Structure tree extraction — PDF/UA and PDF/A documents encode their logical structure (headings, paragraphs, lists, tables, reading order) in a StructTree; pdftract reads this directly when present, producing accurate semantic output at no extra cost
  • Per-page hybrid routing — each page is independently classified and routed to the appropriate pipeline: vector text extraction, full OCR, or assisted OCR where vector hints improve raster accuracy
  • Structured output with provenance — the primary output is JSON carrying per-span bounding boxes, font name, size, and confidence score alongside the extracted text, not a flat string dump

Output

{
  "pages": [
    {
      "page": 1,
      "blocks": [
        { "kind": "heading", "text": "Introduction", "bbox": [72, 680, 400, 700] },
        { "kind": "paragraph", "text": "...", "bbox": [72, 640, 540, 670] }
      ],
      "spans": [
        { "text": "Introduction", "bbox": [72, 680, 400, 700], "font": "Times-Bold", "size": 14.0, "confidence": 0.99 }
      ]
    }
  ],
  "metadata": { "title": "...", "author": "...", "page_count": 10 }
}

Usage

pdftract extract invoice.pdf            # structured JSON to stdout
pdftract extract invoice.pdf --text     # plain text to stdout
pdftract extract invoice.pdf --output out.json
pdftract serve --port 8080              # HTTP service: POST /extract

Architecture

Rust core with PyO3 Python bindings and a CLI binary. The same binary runs as a command-line tool or as an HTTP microservice — the container deployment is just pdftract serve.

See docs/research/ for technical deep-dives into the PDF specification, font encoding, glyph Unicode recovery, and tagged PDF structure. See docs/notes/ for SDK invocation examples in Python, Node.js, Go, Ruby, Java, Rust, and Bash.

Status

Early development. See docs/plan/ for the implementation roadmap.