OCRmyPDF
$ ocrmypdf 官方出品 低风险OCRmyPDF(ocrmypdf)结合 Tesseract 与 Ghostscript/qpdf 为扫描版 PDF 添加不可见的可搜索文本层,同时保持原图像画质并支持生成 PDF/A 归档格式。提供确定性退出码、--deskew 自动纠偏、--sidecar 纯文本提取以及适合脚本化管道的 -q/--quiet 静默参数。
brew install ocrmypdf ocrmypdf 直接在本地对磁盘上的多页 PDF 编排 Tesseract、Ghostscript 与 qpdf 二进制程序,无需任何 MCP 封装。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
完全非交互运行,支持 --quiet、--sidecar 文本提取与明确的数值退出码,但缺少 --json 输出。
--quiet,--sidecar, and--output-type nonesupport clean scripting- No
--jsonoutput formatting
100% 本地离线处理且无任何网络访问,输入输出文件路径显式分离,并支持 --skip-text 防止误改数字文本页。
- Zero network calls; explicit
input.pdf output.pdfseparation - Deterministic exit codes for CI error handling
在 macOS/Linux 可通过 brew install ocrmypdf 一键连带安装 Tesseract、Ghostscript 与 qpdf,也支持 PyPI 与各 Linux 发行版包管理器。
- One-command
brew install ocrmypdfincludes native Tesseract/Ghostscript deps
可搜索 PDF/A 生成的行业标杆,支持多核并发(--jobs)、自动纠偏与附属纯文本提取。
- Handles
--deskew,--rotate-pages,--sidecar, and PDF/A output
长期稳健维护的官方仓库(ocrmypdf/OCRmyPDF),采用 MPL-2.0 协议。
- Official
ocrmypdf/OCRmyPDFrepo under MPL-2.0
ReadTheDocs 手册详尽,包含实用 Cookbook 配方与完整退出码说明。
- Comprehensive ReadTheDocs manual and exit-code docs
安全边界、鉴权与放权指南
100% 本地离线运行,无需任何凭据或 API 密钥。
MPL-2.0 开源 CLI,本地使用完全免费(注意其底层依赖 Ghostscript 采用 AGPLv3 协议)。
# OCRmyPDF CLI (ocrmypdf) Agent Rules - Always write to a new output path (`ocrmypdf in.pdf out.pdf`) rather than overwriting `in.pdf` in place. - Combine `--deskew` with `--skip-text` so PDFs that already contain text layers do not fail. - Pass `-q` / `--quiet` in automated scripts to suppress progress bars.
Agent 高频安全命令配方
只读查询(安全推荐)
ocrmypdf --output-type none --sidecar extracted.txt --quiet scanned.pdf -
执行 OCR 并仅将提取的纯文本写入 extracted.txt,不生成输出 PDF 文件。
受控写入与预演
ocrmypdf --deskew --skip-text --quiet scanned.pdf searchable.pdf
自动拉直倾斜扫描页、通过 --skip-text 跳过已有文本页并输出 searchable.pdf。
核心优势
- +
brew install ocrmypdf可一站式搞定 Tesseract 与 Ghostscript 原生依赖。 - + 确定性退出码、
--skip-text与--sidecar让批量 PDF 处理流水线非常可靠。
注意事项与踩坑点
- ! 输出为 PDF 与纯文本
--sidecar文件,不支持--json输出。 - ! 对已含文本层的 PDF 使用
--deskew时,必须同时传入--skip-text或--force-ocr,否则会报错退出。