pdf2md/README.md
qz 22165a3c26 Import pdf-to-markdown converter and shorten hosted image suffixes.
Bring the local project into the remote repository and reduce generated image object suffixes to six characters for shorter URLs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-19 14:37:42 +08:00

45 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PDF to Markdown
输入学术论文 PDF调用 MinerU 提取为 Markdown随后把 Markdown 中引用的本地图片上传到 R2 图床,并输出一个纯 Markdown 文件。
## 1. 安装依赖
```bash
cd /home/qingz/projects/pdf-to-markdown
uv venv
source .venv/bin/activate
uv sync
cp .env.example .env
```
`.env` 里的 `MINERU_API_TOKEN` 改成你自己的 MinerU token。
## 2. 运行
```bash
uv run python run.py /path/to/paper.pdf
```
可选参数:
```bash
uv run python run.py /path/to/paper.pdf -o /path/to/output.md --language en
uv run python run.py /path/to/paper.pdf --ocr
uv run python run.py /path/to/paper.pdf --disable-table
uv run python run.py /path/to/paper.pdf --disable-formula
```
## 3. 输出
程序会输出最终生成的 Markdown 文件路径。Markdown 中的图片链接会被替换成绝对地址,上传结构为 `年/月/日/论文名简写/图片文件名`,因此在不同设备上直接打开 Markdown 文件也能看到图片。
## 4. 环境变量
- `MINERU_API_TOKEN`MinerU API token
- `R2_BASE_URL`:图床上传基础地址
- `R2_BEARER_TOKEN`:图床 Bearer token
- `R2_PREFIX`:上传路径前缀
- `R2_PUBLIC_BASE_URL`Markdown 中使用的公开访问基础地址
- `POLL_INTERVAL_SECONDS`:轮询间隔
- `TIMEOUT_SECONDS`:最大等待时间