All commands use the installed pdf2md. Run pdf2md doctor first if unsure.
Got a PDF
│
├─ Academic paper (formulas / tables / multi-column)?
│ ├─ no → pdf2md file x.pdf -o out/ --pipeline doc (PyMuPDF4LLM, fast)
│ └─ yes → pdf2md file x.pdf -o out/ --pipeline paper (MinerU, GPU)
│ └─ MinerU formulas unsatisfying (English only)?
│ → pdf2md file x.pdf -o out/ -t nougat (fallback)
│
├─ Scanned / image-only? → --pipeline paper --lang ch|en (MinerU auto-OCR)
│
└─ Batch?
├─ flat directory → pdf2md dir papers/ -o out/ --pipeline paper
└─ nested tree → pdf2md tree papers/ -o out/ --pipeline doc
pdftotext input.pdf - | head # empty output => image-only, needs OCR
pdfimages -list input.pdf | head # shows embedded image streamsFor image-only PDFs, always use --pipeline paper (MinerU) with a --lang
hint. doc/docling will emit empty or garbled text.
# General documents, flat directory (fast)
pdf2md dir reports/ -o out/ --pipeline doc
# Papers, recursive, mirror the input tree
pdf2md tree library/ -o out/ --pipeline paper -l enCommon --lang values: ch, en, ja, ko. Full list in MinerU docs.
Runs automatically. To inspect / re-run manually:
python -m pdf2md.postprocess out/paper.md --detect-only # report PUA chars
python -m pdf2md.postprocess out/paper.md -i # fix in place
python -m pdf2md.postprocess out/*.md -i # batch| Tool | Limit |
|---|---|
| PyMuPDF4LLM | no OCR, no formula recognition |
| Docling | first run downloads ~1 GB of models |
| MinerU | needs GPU; transformers pinned 4.49.0; Chinese decimal points need post-processing |
| Nougat | English papers only, may hallucinate, unmaintained |