# paper2md

Precision PDF-to-Markdown converter for research papers.

## Features

- **Title, author, and abstract extraction** from diverse paper formats
- **Heading hierarchy** detection via font size, weight, and allcaps analysis
- **Math rendering** with CM font-to-LaTeX mapping (~120 symbols)
- **Tables** detected via line-based layout, output in pipe format
- **Figures** from raster (xref), vector (drawings), and clustered composites
- **References** with bracket and alphanumeric key parsing
- **OCR fallback** for scanned PDFs (PyMuPDF OCR or pytesseract)
- **Multi-column support** via 1D clustering with adaptive thresholds
- **MCP server** with tools for PDF conversion, structured extraction, and metadata

## Installation

```bash
pip install paper2md
```

With MCP server support:

```bash
pip install paper2md[mcp]
```

With OCR support for scanned PDFs:

```bash
pip install paper2md[ocr]
```

## Usage

### CLI

```bash
paper2md paper.pdf -d output/
```

This writes the Markdown file and all extracted figure images to the output directory.

### Python API

```python
from paper2md import convert

result = convert("paper.pdf")
print(result.markdown)
```

### MCP Server

paper2md exposes three MCP tools: `convert_pdf`, `convert_pdf_structured`, and `extract_metadata`. Configure your MCP client to launch `paper2md.mcp_server`.

## Tested Formats

paper2md is tested against papers from the following venues and publishers:

arXiv, NeurIPS, CVPR, ICLR, IEEE, ACM, NAACL, Meta AI, DeepMind, JMLR, Nature, Springer

## Requirements

- Python 3.10+
- PyMuPDF 1.24+

## License

MIT
