{
  "id": 20387122,
  "title": "Making Scanned PDFs Searchable with OCRmyPDF and Tesseract",
  "url": "https://urgent.news/2026/11/17/making-scanned-pdfs-searchable-with-ocrmypdf-and-tesseract",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-17T05:58:56.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/onefilekit/making-scanned-pdfs-searchable-with-ocrmypdf-and-tesseract-2i04"
  },
  "original_language": "en",
  "account": "A scanned PDF appears as a typical document, but it functions like a series of images. It cannot be searched, paragraphs cannot be copied, and text extraction tools often return empty results. This issue is common when dealing with email attachments that are actually photographs of printed pages. Here's how to differentiate and add a genuine text layer using OCRmyPDF and Tesseract.\n\nTo determine if a PDF is indeed a scan, the simplest method is using pdftotext from poppler-utils. Running pdftotext input.pdf - will output the text to the terminal. If only a blank line or a form-feed character is displayed, there is no underlying text layer. If the file is already readable and you can highlight and copy text, no additional OCR is required. However, some PDFs may contain a mix of scanned pages and regular text, such as a report exported from Word with a few scanned signature pages at the end. This distinction is important when choosing subsequent actions.\n\nTesseract is the primary OCR engine, capable of identifying characters in images. It can be executed directly on PNG images with tesseract page.png stdout. Converting a PDF requires additional steps, as each page must be rendered as an image, OCR'ed, and a hidden text layer added back to the original page, preserving its appearance. OCRmyPDF simplifies this process by handling the entire pipeline, utilizing Tesseract and other PDF libraries to generate a searchable PDF.\n\nTo install OCRmyPDF, along with Tesseract and a language pack (such as tesseract-ocr and tesseract-ocr-eng for English), use package managers like apt on Debian/Ubuntu or Homebrew on macOS. The basic command, ocrmypdf -l eng --output-type pdf input.pdf searchable.pdf, instructs Tesseract to recognize English text and outputs a searchable PDF. Specifying --output-type pdf ensures the result is a standard PDF, avoiding the default PDF/A-2b format, which, while useful for archiving, may cause conversion issues on certain files.\n\nAfter the conversion, re-running pdftotext confirms the success of the OCR process. The searchable PDF now allows text selection and copying, with the text appearing as an invisible layer on top of the original image. For efficiency, one can create a sidecar text file alongside the searchable PDF using the --sidecar option. This is particularly useful when the text is needed for further processing without parsing the PDF again.\n\nOCRmyPDF supports various input formats, including images, not just PDFs. Adjustments like --image-dpi can be made to optimize the OCR process for images lacking embedded DPI information. The tool also provides options for handling mixed-language documents and selectively OCR'ing specific pages through flags like --skip-text and --force-ocr. These features allow for fine-tuning the OCR process based on the specific characteristics of the document.\n\nSeveral additional flags enhance the OCR process, such as --pages to process a subset of pages, --rotate-pages to correct pages scanned in the wrong orientation, and -j to parallelize the processing of multiple pages. However, the accuracy of the OCR output heavily depends on the quality of the scan. Factors like skewed photos, small text, overlays, and heavy compression can lead to errors. Careful review of the results is essential to correct any mistakes, as OCR is practical but not foolproof.\n\nFor those who prefer a simpler solution for individual PDFs, online tools like OneFileKit offer a user-friendly interface to upload a PDF, select the desired language and output format, and download the searchable file. These services automatically handle the OCR process and delete uploaded files after a short period. However, when dealing with large batches or complex documents, OCRmyPDF remains the preferred choice due to its powerful features and flexibility.",
  "summary": "A scanned PDF looks like a normal document, but it behaves like a stack of photographs. You can't search it, you can't copy a paragraph, and a lot of scripts that \"extract text\" come back empty. I run into this constantly while building file tools: someone emails a \"PDF\" that is really a photograph of a page. Here's how I tell the difference, and how I add a real text layer with OCRmyPDF and…",
  "key_points": [
    "Scanned PDFs appear as images, not searchable text",
    "pdftotext reveals lack of text layer in unreadable PDFs",
    "OCRmyPDF simplifies converting PDFs to searchable formats"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}