Fast, private, and free PDF-to-Markdown conversion using a local LLM (e.g., Gemma 3 via Ollama). No cloud APIs, no tokens, no privacy concerns — just elegant Python.
Article: Convert PDFs to Markdown using Local LLMs — Fast, Private, and Free
Installation (Option 1: Using uv)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv pip install -r requirements.txtThen run:
uv run src/pdf2md.pypython -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtThen run:
python src/pdf2md.py- PyMuPDF (for PDF rendering) — not free for commercial use
- Pillow
- Ollama
- A local model like gemma3:12b or gemma3:4b must be installed and pulled
Use pdf2image + Poppler instead of pymupdf.
brew install poppler # or sudo apt install poppler-utils
pip install pdf2image pillow ollamaThen run:
python src/pdf2md_poppler.py- Handles scanned PDFs via image input
- Converts to clean, structured Markdown
- Works offline with local models
pip install pdf2image
brew install poppler # or in Linux: sudo apt install poppler-utils