Tools,

Copy text from a scanned PDF, then fix the paste

OCR adds the missing text layer:

ocrmypdf scan.pdf searchable.pdf

Then copy. Expect a break at every printed line.

Get the clean-up line

Top: 12 lines from page 1 as Preview's engine (PDFKit) gives them, each ending in a red line break mark, the paragraph end too, and the word Drawing cut as Draw- at a line end. Bottom: the same words after the clean-up line, one flow of text with Drawing whole and no paragraph break.

Three steps, all free

  1. Install it: brew install ocrmypdf (macOS) or sudo apt install ocrmypdf (Linux, often an older version; we tested 17.13).
  2. Run the command above. searchable.pdf keeps each page picture and adds the words as invisible text.
  3. Open searchable.pdf, then select all and copy. For whole pages, add --sidecar text.txt: it gets the same words, with blank lines at paragraph ends.

10 pages copied: 195 stray line breaks

10 OCR'd book pages, read with Preview's engine (PDFKit)
What we counted Copied Cleaned up
Words right, in order 96.0% 96.0%
Line breaks inside paragraphs 195 0
Words cut by a hyphen 11 0
Paragraph ends, of 18 checked 18, each a plain line break 0
Real hyphens lost 0 1

The 4% it misses are OCR misreads, mostly at quote marks, not copy errors: OCRmyPDF's own text file has the same 1,876 right words. We read each engine's text call. No app was clicked.

Your PDF viewer changes the text

One searchable.pdf (ocrmypdf defaults), 4 engines
Engine (apps) Breaks inside paragraphs One-word lines Also
PDFKit (Preview, Safari) 195 7 11 words cut, like gath-⏎ered
PDFium (Chrome uses it) 195 6 Words whole, U+FFFE where 12 hyphens were
MuPDF (SumatraPDF uses it) 270 50 11 words cut
Poppler pdftotext (Linux) 270 81 6 words cut, some out of order

PDFium's text call puts U+FFFE, an invisible noncharacter, where a line-end hyphen was: Draw[U+FFFE]ing. Chrome's copy code deletes that mark, so a Chrome paste reads Drawing. From Chromium's code, not tested.

With --pdf-renderer sandwich, MuPDF and Poppler gave 16 and 26 one-word lines. Preview's engine gave the same text, byte for byte.

Two columns: pdftotext jumps across

A 2-column page set, printed to pictures, then OCR'd
Engine Words in order Column switches (7 = column by column)
PDFKit 99.5% 7
PDFium 98.7% 6
MuPDF 98.7% 10
Poppler pdftotext 62.6% 144

pdftotext put short runs of lines, often one line, from each column in turn. It did the same after all 3 OCR routes.

The clean-up line

perl -CSD -0777 -pe '
  s/\r\n?/\n/g; s/\x{FFFE}//g; s/\h+$//mg;
  s/(\w)[-\x{2010}]\n\h*(\w)/$1$2/g;
  s/(?<!\n)\n\h*(?!\n)/ /g' copied.txt > clean.txt

Paste into a plain text file, copied.txt. Perl comes with macOS and most Linux.

On text.txt it kept all 19 paragraph ends it could check. Poppler copies kept 32 to 181 stray breaks, at blank lines Poppler adds.

Or skip the copy

PDF OCR to Markdown, our Apify Actor, OCRs a scanned PDF and returns its text. Set "outputFormat": "text".

What I did not test

How I tested it
  • Scan: 10 proofread public domain book pages (1,955 words), one picture a page, no text layer.
  • Two columns: the same words set in 2 columns on 4 pages, printed to gray pictures at 300 dpi.
  • OCR: ocrmypdf with defaults (it also wrote text.txt), ocrmypdf --pdf-renderer sandwich, and tesseract's own pdf output.
  • Copy: PDFKit select all (Preview's engine), pypdfium2 (PDFium), pdftotext (Poppler) and PyMuPDF (MuPDF).
  • Line breaks count only between 2 words that sit side by side in the true text. Paragraph ends count where both words lined up: 18 of 29 on the scan, as OCR misreads at quote marks hid the rest.
  • Our Actor: text output, 1 worker, on this Mac. Build 0.1.139 read the scan; build 0.1.140's code read the 2 columns.
  • OCRmyPDF 17.13.0, Tesseract 5.5.4, Poppler 26.03.0, pypdfium2 5.14.0, PyMuPDF 2.1, perl 5.34.1, macOS 26.6.
  • Scripts and results stay in our private repo, in research/bench/copy-text-from-scanned-pdf-2026-11-24/.
Sources

Questions people ask

Why can't I copy text from a scanned PDF?

Each page is a picture with no text layer, so there is nothing to select as text. OCR adds one: ocrmypdf scan.pdf searchable.pdf. Then select and copy work in searchable.pdf.

How do I remove line breaks from text copied from a PDF?

Save it as copied.txt and run our perl line. It joins the lines and the words cut by a hyphen, and keeps blank lines. Copies from Preview's and Chrome's engines had no blank lines at paragraph ends, so paragraphs join too.

Which PDF viewer copies scanned text best?

In our test, the engines in Preview and Chrome: the fewest stray breaks. Chrome's copy code also deletes the U+FFFE mark PDFium puts at line-end hyphens (from its source, not tested). Poppler, the engine of Linux viewers, mixed 2 columns in pdftotext.