Turn PDFs into clean, structured Markdown
Turn PDFs into clean, structured Markdown
pdf2md extracts a PDF's structure - headings, lists, tables, code, math,
links, and images - not just its raw text. It is built on the MIT-licensed
pdfplumber / pdfminer.six, with no
AGPL (PyMuPDF) and no heavy ML/OCR stack anywhere in the dependency tree.
Install, import, and run it as pdf2md.
uv syncuv run pdf2md --pdf_path paper.pdf --out out/
# → writes out/paper.md; extracted images land in out/ and are linked relative to the .md$…$ and display $$…$$ (heuristic)Behaviour is tunable in config/config.yaml.
Core math extraction is heuristic. For accurate equations, install the opt-in ML
extra (pix2tex, which pulls in BSD torch - kept out of the core so the
default install stays lean):
uv sync --extra mathEvery step of the pipeline reports itself, so a long conversion is never a black
box. Steps that walk the pages get a bar; one-off steps print a [pdf2md] line:
[pdf2md] features on: images, borderless tables, blockquotes, footnotes, bold headings
extracting images: 100%|##########| 1477/1477 [01:33 0` is
per-page progress, `total == 0` is a one-off step. The pipeline never imports
tqdm itself, so nothing is pulled in unless you ask for it:
```python
from pdf2md import PdfToMarkdown
PdfToMarkdown(progress=lambda stage, done, total: print(stage, done, total))--extra math).MIT - see LICENSE.
No open issues yet, or sync has not completed.