Configs2026年7月13日·1 分钟阅读

OCRmyPDF — Add Searchable Text Layers to Scanned PDFs

Adds an accurate OCR text layer to scanned PDF files so they become searchable, copy-pasteable, and accessible, while preserving the original scan quality.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
OCRmyPDF Overview
直接安装命令
npx -y tokrepo@latest install 4d40ca36-7eb7-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

OCRmyPDF takes a scanned PDF (image-only) and produces a PDF/A output that contains a hidden text layer under each page image. The text layer is generated by Tesseract OCR and positioned to match the visual layout, making the file fully searchable while keeping the original scan intact.

What OCRmyPDF Does

  • Adds an invisible OCR text layer to scanned PDFs without degrading image quality
  • Produces PDF/A-compliant archival output by default
  • Skips pages that already contain text to avoid double-processing
  • Automatically deskews, cleans, and rotates pages before OCR
  • Supports batch processing of entire directories

Architecture Overview

OCRmyPDF orchestrates a pipeline of external tools: Ghostscript for PDF rendering, unpaper for image cleaning, Tesseract for OCR, and pikepdf for reassembling the final PDF. Each page is processed in parallel. The text layer is positioned using hOCR coordinate data so that selecting text in a viewer highlights the correct region.

Self-Hosting & Configuration

  • Install via pip, conda, or your distro's package manager (apt, brew, etc.)
  • Tesseract and Ghostscript must be available on the system PATH
  • Install extra Tesseract language packs for non-English documents
  • Use --output-type pdfa (default) for archival; --output-type pdf to skip PDF/A conversion
  • Run inside Docker with jbarlow83/ocrmypdf for an isolated environment

Key Features

  • Lossless by default: the original scanned images are not re-encoded
  • Produces PDF/A for long-term archival compliance
  • Multithreaded page processing for fast throughput on multi-core machines
  • Plugin system for custom pre-processing or alternative OCR engines
  • Handles mixed documents (pages with and without existing text)

Comparison with Similar Tools

  • Tesseract CLI — raw OCR to plain text; OCRmyPDF wraps it into a full PDF pipeline
  • Adobe Acrobat — commercial; OCRmyPDF is free and scriptable
  • pdfsandwich — similar concept but fewer configuration options and slower development
  • Paperless-ngx — document management system that uses OCRmyPDF internally

FAQ

Q: Does it reduce scan quality? A: No. By default OCRmyPDF copies the original images without re-encoding.

Q: Which languages are supported? A: Any language Tesseract supports, currently over 100.

Q: Can it process thousands of files? A: Yes. Use a shell loop or GNU parallel; each invocation is self-contained.

Q: Does it work on born-digital PDFs? A: It detects existing text layers and skips those pages unless forced.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产