搜索全部选项#
输入关键词(按 / 聚焦搜索框)或按分组筛选。所示默认值为 CLI 自身的默认值,代码 样式的值为可接受的取值。选项说明保留 CLI 原文(英文),与你在终端中看到的一致。
语法#
docling convert [OPTIONS] SOURCE
docling SOURCE [OPTIONS] # 等价:convert 是默认命令
docling options {ocr|layout|table-structure} [ENGINE]
docling --versionSOURCE 可以是文件路径、文件夹(递归遍历并按 --from 过滤)或 http(s) URL。输出文件以输入文件命名,写入 --output(默认为当前目录)。
测试过的命令示例#
以下每条都在 Docling 2.148.0 上运行过,把文件名换成你自己的即可。
格式与输出
docling convert report.pdf --to md --to json --output out/docling convert ./inbox --from pdf --to md --output ./outdocling convert report.pdf --to md --output-file report.mddocling convert report.pdf --page-range 1-10docling convert report.pdf --to md --image-export-mode referenced --output out/docling convert report.pdf --to html_split_page --show-layoutOCR
docling convert report.pdf --no-ocrdocling convert scan.pdf --ocr-mode full_pagedocling convert contract.pdf --replace-broken-text-layerdocling convert scan.pdf --ocr-engine rapidocr --ocr-option backend=torch --ocr-lang chdocling convert scan.pdf --ocr-engine tesseract --ocr-lang deu,eng表格、增强与模型
docling convert report.pdf --table-mode fastdocling convert report.pdf --heading-hierarchydocling convert paper.pdf --enrich-formula --enrich-codedocling convert report.pdf --pipeline vlm --vlm-model granite_doclingdocling convert meeting.mp3 --pipeline asr --asr-model whisper_turbo --to md --to vttRAG 与自动化
docling convert report.pdf --to chunks --chunks-max-tokens 512 --output chunks/docling convert ./inbox --to json --quiet --fail-on partial --output ./outdocling convert report.pdf --profilingoptions 命令#
引擎的设置比专用参数更多。docling options 列出某个流水线阶段的引擎及其可用键,用对应的 --*-option KEY=VALUE 参数传入。值会尽量按 JSON 解析(0.6、false、["en","de"])。
docling options ocr # auto easyocr kserve_v2_ocr nemotron-ocr ocrmac rapidocr tesserocr tesseract
docling options layout # layout_object_detection docling_layout_default docling_experimental_table_crops_layout
docling options table-structure # docling_tableformer docling_tableformer_v2 granite_vision_table
docling options ocr rapidocr # 键:mode、lang、scale、backend、model_size、text_score……docling convert scan.pdf --ocr-engine rapidocr --ocr-option backend=torch --ocr-option model_size=tiny --ocr-option text_score=0.6退出码#
--fail-on | 何时以 1 退出 |
|---|---|
failure(默认) | 任一文档失败 |
partial | 任一文档失败或仅部分转换 |
never | 从不——始终以 0 退出 |
默认情况下,转换文件夹时遇到失败的文件会继续;加 --abort-on-error 则在第一个失败时停止。
已弃用和改名的参数#
如果旧教程里的命令表现异常,先查这张表。
| 旧参数 | 2.148.0 中的写法 | 原因 |
|---|---|---|
--force-ocr | --ocr-mode full_page | CLI 帮助中标注为 DEPRECATED |
--psm N | --ocr-option psm=N | 标注为 DEPRECATED;引擎设置移到 --ocr-option |
--ocr-lang chinese / english(RapidOCR) | --ocr-lang ch / en,或 iso:zh-Hans | 旧写法仍可识别,但会给出警告 |
远程转换#
安装 service-client 组件后,CLI 会多出 docling convert-remote:它把文档发送到 docling-serve 服务器,并在本地写出结果。它不需要 PyTorch——在我们的测试中环境仅 258 MB。
pip install "docling-slim[service-client]"
export DOCLING_SERVICE_URL=http://localhost:5001
export DOCLING_SERVICE_API_KEY=... # 仅当服务器需要时
docling convert-remote report.pdf --to md --output out/环境变量#
| 变量 | 作用 |
|---|---|
DOCLING_ARTIFACTS_PATH | 预下载模型所在目录(同 --artifacts-path) |
DOCLING_SERVICE_URL、DOCLING_SERVICE_API_KEY | convert-remote 使用的服务器和密钥 |
OMP_NUM_THREADS | 限制底层数学库使用的线程数 |
常见问题
Docling 最基本的命令是什么?
docling convert file.pdf 会把 PDF 转为 Markdown 并保存到当前目录。加上 --to json、--to html 等可输出更多格式,用 --output DIR 指定输出目录。
如何在 Docling 命令行中关闭 OCR?
加上 --no-ocr。对于已包含文本的 PDF,这是正确的选择,在我们的基准测试中快了 3.6 倍。
如何用 Docling 转换整个文件夹?
把文件夹作为 SOURCE:docling convert ./inbox --to md --output ./out。加 --from pdf 只处理 PDF,加 --abort-on-error 则在第一次失败时停止。
如何查看某个 OCR 引擎的全部选项?
运行 docling options ocr ENGINE,例如 docling options ocr rapidocr。它会列出可通过 --ocr-option KEY=VALUE 传入的每个 KEY,以及类型和默认值。
docling convert 的退出码是什么?
默认情况下,只要有文档失败就以 1 退出。--fail-on partial 在部分转换时也会失败,--fail-on never 则始终以 0 退出。