Skip to main content

Fast, fully-local PDF & image (PNG/JPG/...) to Markdown converter with image OCR, plus a ZIP of parsed images. No API calls, runs 100% offline. Supports Python 3.9-3.12.

Project description

pdfmark-ocr

Fast, fully-local PDF → Markdown — with OCR for images. No API calls, no cloud, nothing leaves your machine.

Microsoft's markitdown only reads native text; if a PDF page is a scan or has text inside images, you lose it. pdfmark-ocr reads native text directly (instant) and runs OCR on embedded images, in parallel across your CPU cores.

Install

pip install pdfmark-ocr

That's it — works on Windows, macOS, and Linux (Python 3.9+). The default OCR engine is RapidOCR (ONNX, fast, small).

Usage

pdf2md document.pdf                       # -> full_stitched_output.md
pdf2md document.pdf -o notes.md           # choose output file
pdf2md document.pdf --workers 4           # control parallelism
pdf2md document.pdf --min-image 0         # OCR every image, even tiny ones
pdf2md scanned.pdf --page-ocr always      # render+OCR whole pages (scans/vector text)

You can also run it as a module:

python -m pdf2md_ocr document.pdf

Options

Flag Default Meaning
-o, --output full_stitched_output.md Output markdown path
--engine rapidocr rapidocr (default) or easyocr
--workers auto Parallel page workers
--max-dim 1500 Downscale images larger than this (px)
--min-image 16 Skip images smaller than this (px); 0 keeps all
--page-ocr auto Render+OCR whole pages for vector-drawn/scanned text. auto does only text-poor pages; always does every page; never disables it
--render-dpi 200 Resolution for full-page render OCR

Optional: EasyOCR engine

EasyOCR is heavier (pulls in PyTorch, hundreds of MB) but you may prefer its accuracy on some documents:

pip install "pdfmark-ocr[easyocr]"
pdf2md document.pdf --engine easyocr

How it works

  1. Native text is extracted directly from the PDF — instant, no OCR.
  2. Embedded images are downscaled and sent to the chosen OCR engine. Pages whose text is vector-drawn or scanned (no extractable native text) are rendered to a bitmap and OCR'd whole — controlled by --page-ocr.
  3. Pages are processed in parallel, one OCR engine per worker process.
  4. A per-worker cache means repeated logos/headers are OCR'd only once.

Use from Python

from pdf2md_ocr import stitch_full_pdf

stitch_full_pdf("document.pdf", "out.md", engine="rapidocr")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfmark_ocr-0.3.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdfmark_ocr-0.3.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file pdfmark_ocr-0.3.0.tar.gz.

File metadata

  • Download URL: pdfmark_ocr-0.3.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pdfmark_ocr-0.3.0.tar.gz
Algorithm Hash digest
SHA256 61c7cc05f536f1e202f5cba2d785f27ca920dc28fc013606f10218460f4f5c7e
MD5 3261baabb0d2f2a243ea6d377b826dd1
BLAKE2b-256 6fbfc77c248dfa2b164081e1cecb8baba06b0375ad092114f362bddea6784c7e

See more details on using hashes here.

File details

Details for the file pdfmark_ocr-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pdfmark_ocr-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pdfmark_ocr-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b1816a357164a02d37963b931a862cff3ee8993df62f7fb79565c466547b5e1
MD5 94c3f73be46e6e9c5729f2d62b5e0b34
BLAKE2b-256 9949b4febe84920a32dd671c251a7741c65efeef376dcad5c7525ffbef266d97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page