Forum Discussion
How to copy text from PDF that cannot be copied?
Using Tesseract and OCRmyPDF together is a powerful, completely free, and open-source way to tackle the problem when you can't copy text from PDF files. It's a bit more technical than using a point-and-click tool, but it's incredibly effective because it adds a hidden, searchable text layer right underneath the image of your scanned page. This means you can then select and copy the text just like you would in any normal document, solving the issue of when you can't copy text from PDF through standard methods.
Once everything is installed, open your command prompt or terminal and navigate to the folder with your PDF. Here are the basic commands to get you started:
Basic OCR on a PDF: This is the simplest command. It takes your locked input.pdf, runs OCR, and creates a new searchable output.pdf file.
bash
ocrmypdf input. pdf output. pdf
Specify a language: If your document isn't in English, use the -l flag followed by the language code (e.g., fra for French).
bash
ocrmypdf -l fra input.pdf output. pdf
Force OCR on all pages: If your PDF already has some text but you still want to redo the OCR on the entire thing, use the --force-ocr flag to process the pages as images.
bash
ocrmypdf --force-ocr input. pdf output. pdf
Get a separate text file: If you just want the plain text extracted, you can use the --sidecar option to create a companion .txt file.
bash
ocrmypdf --sidecar output. txt input. pdf output. pdf
Improve accuracy for messy scans: For documents that are crooked or have a noisy background, you can add commands like --deskew (to straighten) and --clean (to reduce noise), which can significantly improve text recognition accuracy.
bash
ocrmypdf --deskew --clean input. pdf output. pdf
If you can't copy text from PDF, this method might feel a bit "under the hood," but it's incredibly reliable and gives you full control over the process. It's a fantastic skill to have when you run into a PDF that just won't cooperate.