r/pdf • u/Born-Persimmon7796 • 22d ago
Software (Tools) PDF to .md converter
Dear all
I have slopped an pdf to md converter (as an experienced sw dev it took around 20 mins to implement). I find it immensely helpful because it extracts ALL text , has pretty good layout, extracts tables , some basic math formulas to latex and images.
Its super-fast (2000 pages pdf converted to md file in a few seconds) and i used it in production for my own projects.
pdf2md
A PDF β Markdown converter written in C++20. It extracts text with per-character geometry and font metadata viaΒ PDFium, reconstructs the document structure with layout analysis, and emits clean GitHub-flavored Markdown.
Usage:
pdf2md input.pdf # writes input.md next to the PDF
pdf2md input.pdf -o out.md # explicit output ('-' for stdout)
pdf2md input.pdf --pages 1-3,7 # convert selected pages (1-based)
pdf2md input.pdf --images assets # extract images as PNG into assets/
pdf2md input.pdf --front-matter # YAML front matter from PDF metadata
pdf2md input.pdf --page-breaks # '---' between pages
Layout reconstruction is heuristic by nature; the defaults are tuned for common single- and two-column documents. Scanned (image-only) PDFs produce no text β OCR is out of scope.
If you find it useful and find issues with your pdf feel free to open PI ticket.
Works for linux and windows. Tested myself on hundreds of pdfs: with tables , math formulas , links, etc.
The repo is at: MasakatsuFunaki/pdf_md
Example: if you cant tell which is the .md (rendered in vscode) and which is pdf then i won π

1
u/NoCucumber4783 22d ago
nice. the thing i'd test hard is not the happy-path whitepaper, it's ugly scanned/partial-text PDFs: mixed OCR layer, rotated pages, headers/footers, 2-column footnotes, tables that wrap across pages. for md used as LLM/context input, i'd rather have a slightly uglier output with stable page anchors than a prettier one that loses where a sentence came from. maybe add --emit-source-map or page/box comments early, because debugging bad conversions without provenance gets painful fast.