pdfni
A Rust library that extracts tables and Markdown from text-embedded PDFs. To pursue both accuracy and speed, it ships with its own pure-Rust PDF reader adapted from Mozilla pdf.js. Usable as a Rust crate, a CLI, or a WebAssembly module from Node.js and the browser.
Expect breaking changes.
Highlights
- Table extraction — solid for ruled and text-aligned layouts; support for merged cells is limited (how it works)
- Markdown extraction from the document model (paragraphs, headings, lists, tables) (pipeline)
- Built-in pure-Rust PDF reader adapted from pdf.js — no OCR, no page rasterization, no system PDF library (reader lineage)
- Native, Node.js, and browser via WebAssembly (wasm guide)
What it is not
- OCR for scanned / image-only PDFs
- A full PDF renderer (images, annotations, forms, signatures are out of scope)
- Vertical-writing-aware table detection (the reader can surface vertical text; table detection stays oriented to horizontal layout)
Quick Start
CLI
Prints the table Document JSON to output.json. See docs/CLI.md
for modes and encrypted PDFs.
Rust
use ;
Benchmarks
Full pipeline (table regions are not given), scored with each benchmark's
official evaluation tool. Scripts and test data live under
bench/ — see each benchmark's README for setup.
| Benchmark | Task | Precision | Recall | F1 |
|---|---|---|---|---|
| ICDAR 2013 original (eu + us) | Region detection (char-level) | 0.9347 | 0.9316 | 0.9332 |
| ICDAR 2013 original (eu + us) | Structure (cell adjacency) | 0.9403 | 0.9335 | 0.9369 |
| ICDAR 2013 corrected (eu + us) | Region detection (char-level) | 0.9347 | 0.9316 | 0.9332 |
| ICDAR 2013 corrected (eu + us) | Structure (cell adjacency) | 0.9403 | 0.9335 | 0.9369 |
| SciTSR test (3,000 tables) | Structure (cell adjacency, macro) | 0.9254 | 0.8997 | 0.9124 |
Documentation
- Building and feature flags
- CLI usage
- WebAssembly (Node.js and browser)
- Architecture and internals
- API reference on docs.rs
License
Licensed under the Apache License, Version 2.0. See LICENSE.
Third-party notices
The bundled PDF reader is adapted from Mozilla pdf.js, and the bundled binary CMap data is derived from Adobe CMap resources. See NOTICE for attribution and license details.