Metadata-Version: 2.4
Name: pdfmark-ocr
Version: 0.2.0
Summary: 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.
Author: Chetan Singhal
License-Expression: MIT
Project-URL: Homepage, https://github.com/Chetan-31D4/pdfmark-ocr
Project-URL: Issues, https://github.com/Chetan-31D4/pdfmark-ocr/issues
Keywords: pdf,markdown,ocr,convert,rapidocr,offline,local
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Text Processing :: Markup :: Markdown
Classifier: Topic :: Utilities
Requires-Python: <3.13,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyMuPDF>=1.23
Requires-Dist: pillow>=9.0
Requires-Dist: rapidocr_onnxruntime>=1.3
Provides-Extra: easyocr
Requires-Dist: easyocr>=1.7; extra == "easyocr"
Requires-Dist: torch>=2.0; extra == "easyocr"
Provides-Extra: app
Requires-Dist: streamlit>=1.30; extra == "app"
Dynamic: license-file

# 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

```bash
pip install pdfmark-ocr
```

That's it — works on **Windows, macOS, and Linux** (Python 3.9+). The default OCR
engine is [RapidOCR](https://github.com/RapidAI/RapidOCR) (ONNX, fast, small).

## Usage

```bash
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
```

You can also run it as a module:

```bash
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 |

## Optional: EasyOCR engine

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

```bash
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.
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

```python
from pdf2md_ocr import stitch_full_pdf

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

## License

MIT
