Skip to content
Artificial intelligence. Clearly. RSS feed
AI NEWS AI

News. Evidence. Perspective.

Build & CodeExplainer

Make a mixed PDF searchable without losing its existing text

A scan and a digital page can need different treatment. Our two-page OCRmyPDF test produced a searchable document, a useful transcription error and two text files with different contents.

The room notes became searchable; the booking confirmation kept its existing text. That was the useful result when we ran OCRmyPDF on an original two-page PDF containing one page image and one digital page. The accompanying OCR text file, however, contained only the room notes. Knowing which output to keep is part of finishing the job.

OCRmyPDF adds a text layer to page images so that words can be searched and selected. It uses Tesseract for recognition. Tesseract includes a neural network trained to recognise lines of text: that is the AI component in this local document workflow.[1][2]

The small document we actually checked

AI News created two short pieces of practice material. Page one, headed “Workshop room notes”, was rasterised at 300 dots per inch and embedded as an image. It included the reference ARCHIVE-742. Page two, “Booking confirmation”, retained ordinary PDF text, including BOOKING-319. Before conversion, text extraction returned nothing from page one and the complete wording from page two.

Our Linux run used OCRmyPDF 15.2.0+dfsg1 and Tesseract 5.3.4 with English language data. After conversion, both references appeared in the PDF’s extracted text. Page two’s extracted wording was unchanged. Rendering the input and output at 110 dpi produced identical pixel data for each page, and we inspected the rendered pages.

Recognition still made a specific mistake: the image page’s footer “AI News” became “Al News”, with a lowercase l replacing the capital I. The same footer on the digital page stayed correct. A clean page image can therefore look unchanged while its newly searchable wording contains an error.

Set up the same kind of conversion

This route uses a terminal: a window where you enter commands. On Debian or Ubuntu, install the distribution’s OCRmyPDF package and Poppler utilities with the command below. Package versions can lag behind the latest OCRmyPDF release. The project also documents Homebrew installation for macOS and a Windows Subsystem for Linux route; our executed example was on Linux.[3][4]

Check the installation with ocrmypdf --version, then tesseract --list-langs. This example needs eng in the language list. For another language, install its Tesseract language data and change the language code in the conversion command. Poppler supplies pdftotext, which we use for the complete text export.[5][4]

Make a fresh working folder, put a copy of your PDF inside it and name that copy input.pdf. Open a terminal in that folder. Choose a small document whose pages you can check against the original. Try selecting a sentence on each page first: the useful case here combines page images with text that already works.

The skip option leaves pages containing text out of OCR. The command writes a standard PDF, disables image optimisation and saves newly recognised text separately. For an existing but faulty text layer, use the project’s redo-OCR guidance instead of assuming this command will repair it.[6]

Wait for the command to finish successfully, then open searchable.pdf in your PDF reader. Search for a distinctive reference from an image page and another from a digital page. Copy several lines, including names or credits, into a text editor and compare them with the visible page. Checking the footer this way exposes our AI/Al error.

Save the text that covers the whole document

At a glance

What our three output files contained

What our three output files contained
FileObserved content
searchable.pdfBoth pages; both reference codes searchable
ocr-only.txtRecognised room notes and a marker for skipped page 2
all-pages.txtText from both pages, including both reference codes

Open all-pages.txt and confirm that material from every page is present. Keep searchable.pdf beside the original input so a search hit can return to the visible wording. If you correct a transcription in the text file, give the corrected copy its own name: changing that file does not change the text already embedded in the PDF.

Follow the evidence

Sources & further reading

  1. Introduction OCRmyPDF · Accessed 19 Oct 2026
  2. Tesseract OCR Tesseract project · Accessed 19 Oct 2026
  3. Installing OCRmyPDF OCRmyPDF · Accessed 19 Oct 2026
  4. poppler-utils package Debian · Accessed 19 Oct 2026
  5. Installing additional language packs OCRmyPDF · Accessed 19 Oct 2026
  6. Cookbook OCRmyPDF · Accessed 19 Oct 2026