Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 13, 2026·2 min de lecture

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.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
OCRmyPDF Overview
Commande d'installation directe
npx -y tokrepo@latest install 4d40ca36-7eb7-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en 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

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires