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- Headings from document-wide font-size statistics
- Text: paragraphs (de-hyphenated), bold / italic / inline code, super/subscript, links
- Lists (ordered, unordered, nested), blockquotes, horizontal rules
- Code blocks via monospace-font detection
- Tables - ruled and borderless, as GFM pipe tables
- Math → LaTeX - inline
$…$and display$$…$$(heuristic) - Layout - multi-column reading order, rotated/landscape pages, header/footer stripping
- Footnotes, table of contents, images, and CJK / Unicode text
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 math- No OCR - scanned / image-only pages yield embedded images only.
- Math is heuristic - complex equations are best-effort (use
--extra math). - Dense multi-table pages and right-to-left scripts may need manual review.
MIT - see LICENSE.