Show HN: Offline Python table extractor for digital and scanned PDFs A developer released an open-source Python tool that extracts tables from digital and scanned PDFs entirely on-device, combining a native OpenCV multi-table detector, a PDFium native text fast path via pypdfium2, and RapidOCR running on ONNX Runtime, with no cloud services, API keys, or telemetry. The tool's native text-layer path is claimed to be 40×–80× faster than OCR, processing a 16-page warn_report.pdf in 0.95 seconds with zero OCR typos, and it groups tables with matching columns into separate schema-matched CSV files or Python data structures. It accepts PDFs, single images, image folders, and in-memory bytes or PIL images, and supports CPU, NVIDIA CUDA, and AMD ROCm acceleration. 100% local, private, zero-config table extraction powered by a native OpenCV multi-table engine + PDFium native text fast path + RapidOCR — extracts all tables from PDFs, single/multiple images, or folders of images and automatically groups tables with matching columns into separate, schema-matched CSV files or Pythonic data structures, with automatic native-text vs. OCR routing, multi-core CPU parallelism, pluggable/installable RapidOCR language packs, repeated-header & headerless-continuation merging, stacked header flattening, implicit sub-row splitting, headless visual debugging, and CPU / NVIDIA CUDA / AMD ROCm acceleration. 100% Local & Private: Everything runs entirely on your own machine — no cloud services, no external API keys, no telemetry, and no documents ever leave your environment. Once language models are cached or pre-installed via pdf2csv-tables languages install , extraction works completely offline / air-gapped . - 100% local & offline-ready engine OpenCV + RapidOCR : Runs completely on-device via ONNX Runtime or local PyTorch GPU — no cloud APIs, no API keys, no external OS binaries, and zero network calls during extraction once models are cached. - Unified PDF & image inputs CLI and Python library : - Accepts PDFs --pdf-mode render default via pypdfium2 , or --pdf-mode embedded raw scan extraction with automatic logo filtering & render fallback on hybrid PDFs , - Single images .png , .jpg , .jpeg , .webp , .tif , .tiff , .bmp , including multi-frame TIFFs and automatic EXIF orientation , - Multiple images or a folder of images naturally sorted page 1.png, page 2.png, ..., page 10.png and processed seamlessly like pages of a multi-page PDF , - In-memory inputs in Python bytes for PDFs or images, PIL.Image.Image , or sequences of images/paths . - Accepts - Native OpenCV multi-table & borderless detector + fast native PDF text layer: - Connected-component morphological grid & joint detector finds all bordered tables on every page while ignoring prose, diagrams, and decorative page frames. - Automatic native PDF text-layer fast path --text-source auto , default : extracts exact word coordinates directly via pypdfium2 on digital PDFs 40×–80× faster , 0.95 s for 16-page warn report.pdf , zero OCR typos and automatically falls back to RapidOCR on image-only scans, raster images, or broken font maps. Override anytime with --text-source ocr or --text-source native . - Auto-deskews tilted scans --deskew while skipping redundant deskew on straight digital PDFs. - Splits tall unruled data bands e.g., 5-row visual grouping blocks into individual rows while preserving wrapped multi-line prose cells. - Detects horizontally merged cells from missing vertical dividers and extracts whitespace-aligned borderless tables --borderless . - Paired with tuned single-pass RapidOCR onnxruntime with table-ROI cropping on prose-heavy scans --no-borderless and configurable multi-core CPU parallelism --workers / -j / PDF2CSV WORKERS . - Connected-component morphological grid & joint detector finds - Smart column detection, repeated headers & headerless continuations: - Handles multi-page tables with repeated headers on every page , without repeated headers headerless continuations , or mixed headers repeated on some pages and omitted on others . - Deduplicates repeated single-row, 2-row stacked/spanning, and mid-table headers automatically or keep them via --keep-repeated-headers . - Promotes full-width banner titles into manifest.json schema.title and flattens stacked 2-row spanning headers into clean column names. - Fuzzy-matches column headers across pages Unicode-safe for Latin, Cyrillic, Hebrew, Arabic, CJK; absorbs OCR typos like Descriptlon ↔ Description . - Matches headerless continuations via column count, normalized/table-relative column spans even on margin-shifted duplex scans , and column data-type profiles. - Keeps tables with different headers in separate CSV files — even when they share the same column count. - Handles multi-page tables - Pluggable & user-installable RapidOCR language packs: - Built-in support for English, European Latin de , fr , es , it , pt , nl , pl , sv , da , fi , no , cs , hu , ro , tr , vi , ... , Cyrillic ru , uk , bg , sr , be , Arabic ar , fa , ur , Chinese zh , zh tw , Japanese ja , Korean ko , Devanagari hi , Thai th , Greek el , Tamil ta , Telugu te , and Kannada ka . - Manage offline/cached models languages list , languages install , languages remove , add custom ONNX recognition models + character dictionaries languages add , .zip /folder packs , or plug in Python packages via entry points pdf table extractor.languages . - Built-in support for English, European Latin - Hardware acceleration: Automatic --device auto|cpu|cuda|rocm routing, pdf2csv-tables doctor diagnostics, and multi-target Docker images cpu , cuda , rocm . | Capability | pdf-to-csv-table-extractor | Camelot | Tabula-py | pdfplumber | Docling | |---|---|---|---|---|---| | Zero external OS binaries no Java / Ghostscript / Tesseract / Poppler | Yes | No Ghostscript | No Java JVM | Yes | Yes | | Digital PDFs fast native text layer | Yes 0.95 s / 16p | Yes | Yes | Yes | Yes | | Scanned PDFs, tilted scans & image folders | Yes auto-deskew + RapidOCR | No | No | No | Yes heavier DL models | | Stamped / hybrid scans vector text + tilted scan | Yes automatic fallback | No | No | No | Yes | | Multi-page schema-matched CSV merging repeated + headerless | Yes automatic | Manual | Manual | Manual | Manual | | Lightweight install & CPU / CUDA / ROCm | Yes ONNX Runtime / PyTorch | CPU | CPU | CPU | PyTorch / heavy | | Outputs | CSV, ZIP, JSON, Markdown, DataFrame, Polars | CSV, JSON, DataFrame | CSV, JSON, DataFrame | Lists / dicts | Markdown, JSON, DocTags | Input: PDF / Image s / Folder / bytes │ ▼ 1. Document Loader pypdfium2 raster + native text boxes / PIL, EXIF, lazy --pages │ ▼ Multi-core CPU worker pool via --workers / -j / PDF2CSV WORKERS 2. Preprocessing auto-deskew on scans; skipped on straight digital PDFs │ ▼ 3. Native OpenCV Grid Detector bordered grids, horizontal merges, sub-rows & borderless │ ┌────────┴────────────────────────────┐ ▼ --text-source auto: digital PDF ▼ scanned PDF / images / --text-source ocr 3a. Native PDF Text Layer 3b. Tuned RapidOCR table-ROI crop on prose scans exact PDFium word boxes, ◄── Pluggable Language Packs ONNX / plugins ~11 ms/page, zero OCR typos ◄── Accelerator CPU / NVIDIA CUDA / AMD ROCm └────────┬────────────────────────────┘ ▼ 4. Column & Schema Engine repeated & headerless merging, banner strip, stacked header flatten │ ▼ 5. Per-Schema CSVs / Pythonic API + manifest.json + debug overlays Requires Python 3.11 – 3.14 Linux, macOS, Windows . With pip 100% local, CPU-ready, zero external OS binaries pip install pdf-to-csv-table-extractor Optional Arabic / Persian / Urdu RTL support installs python-bidi pip install "pdf-to-csv-table-extractor rtl " Or with uv uv add pdf-to-csv-table-extractor Or run one-shot via uvx without creating a virtualenv uvx --from pdf-to-csv-table-extractor pdf2csv-tables extract document.pdf -o output/ Optional NVIDIA CUDA ONNX Runtime acceleration swap CPU onnxruntime AFTER install pip install pdf-to-csv-table-extractor pip uninstall -y onnxruntime && pip install "onnxruntime-gpu =1.18.0" Install from a local git checkout git clone https://github.com/vitali84/pdf-to-csv-table-extactor.git cd pdf-to-csv-table-extactor uv sync or: pip install . Note: The example PDFs under samples/ are available in the GitHub repository https://github.com/vitali84/pdf-to-csv-table-extactor/tree/master/samples excluded from the PyPI wheel to keep installs lean . Substitute any local PDF, image, or folder of images. pdf2csv-tables extract samples/warn report.pdf --pages 1 -o output/ --debug-dir debug out/ Ignores the agency logo, title block, and publication note, detects the 7-column header and all 36 data rows , and writes a schema-named CSV alongside its manifest: | Notice Date | Effective | Received | Company | City | No. Of | Layoff/Closure | |---|---|---|---|---|---|---| | 06/22/2015 | 03/25/2016 | 07/01/2015 | Maxim Integrated Product | San Jose | 150 | Closure Permanent | | 06/30/2015 | 08/29/2015 | 07/01/2015 | McGraw-Hill Education | Monterey | 137 | Layoff Unknown at this time | | 06/30/2015 | 08/30/2015 | 07/01/2015 | Long Beach Memorial Medical Center | Long Beach | 90 | Layoff Permanent | | 07/01/2015 | 09/02/2015 | 07/01/2015 | Leidos | El Segundo | 72 | Layoff Permanent | | 07/01/2015 | 09/30/2016 | 07/01/2015 | Bosch Healthcare Systems, Inc. | Palo Alto | 55 | Closure Permanent |