Why you can't copy text from some PDFs, or get gibberish

Updated · Tested with pypdf 7.2.0, pdfminer.six 20260107, PyMuPDF 2.2, Poppler 25.03, OCRmyPDF 17.14

In short

Either the page is a picture with no text in it, or the file leaves out the table that says which letter each shape stands for, so copying gives symbols. A scan needs OCR. A file with a missing table can often be read by a tool that looks inside the font, and otherwise needs OCR too. A third cause is the author switching copying off.

A PDF is a description of how a page looks, not of what it says. Whether you can copy its text depends on how the file was made. There are four causes, and each has a different fix.

What happensCauseFix
Nothing can be selectedThe page is a picture: a scan or a photoOCR
Text selects but pastes as symbolsThe font has no table saying which letter each shape isRead the font itself, or OCR
Copying is greyed outThe author switched copying offThe password, or the author
Text pastes, but words are missing letters or run togetherJoined letters and missing spacesA better extractor

1. The page is a picture

A scanner or a phone camera produces an image. Saved as a PDF, it is still an image: there are no letters in the file, only dots. You can check in any viewer: if you cannot select a single word, it is a scan.

The fix is OCR, which reads the picture and writes the text back in. Scanned or searchable? shows how to check a file in code and how to make it searchable.

2. The text pastes as gibberish

This is the confusing one. The page looks perfect, you can select the words, and what you paste is this:

Output
&203$1<(;75$&7
&RPSDQ\QDPH +DUERU/DQH/RJLVWLFV/WG

A PDF does not store letters. It stores numbered shapes from a font, plus a table, called ToUnicode, that says which letter each number stands for. When the program that made the PDF leaves that table out, the viewer can still draw the page, but nobody is told that shape 38 is a "C".

no-unicode-map.pdf is the sample extract with those tables removed. You can see that they are missing:

Python
from pypdf import PdfReader

reader = PdfReader("no-unicode-map.pdf")
for name, ref in reader.pages[0]["/Resources"]["/Font"].items():
    font = ref.get_object()
    print(font["/BaseFont"], "has a map" if "/ToUnicode" in font else "no ToUnicode map")
Output
/HUHQIP+Noto-Sans no ToUnicode map
/SDIUIR+Noto-Sans-Bold no ToUnicode map

Fix one: a tool that reads the font. The font file inside the PDF usually still knows which letter each shape is. Some tools look there when the table is missing, and some do not. On this file:

ToolResult
pypdfGibberish
PyMuPDFGibberish
pdftotextGibberish
pdfminer.six, pdfplumberCorrect text
100sandsCorrect text
Python
from pdfminer.high_level import extract_text

print(extract_text("no-unicode-map.pdf")[:29])
Output
COMPANY EXTRACT

Company name

Fix two: OCR the page anyway. When the font is no help either, treat the page as a picture. OCRmyPDF renders each page, reads it, and writes a new PDF with a correct text layer:

Shell
ocrmypdf --force-ocr no-unicode-map.pdf fixed.pdf

After that, pypdf reads fixed.pdf as COMPANY EXTRACT, Company name Harbor Lane Logistics Ltd, and so on. --force-ocr is needed because the file already has text, even though it is the wrong text.

3. Copying is switched off

A PDF can carry permissions: printing allowed, copying not. Viewers respect them and grey out Copy. This is a setting, not encryption of the content, and it is the author's decision; ask for an unrestricted copy. A file that needs a password just to open is a different case, covered in password-protected PDFs.

4. Letters go missing or words run together

Two smaller effects produce text that is almost right.

Joined letters. Many fonts draw "fi", "fl" or "ffi" as a single shape, called a ligature. A careless extractor returns that shape as one odd character or drops it, so "office" becomes "oce" or "ofce". Every library we tested handles this correctly today; if you see it, update your tools.

Missing spaces. A PDF often has no space characters at all: words are simply placed apart. The extractor has to guess where a gap is wide enough to be a space. Too strict, and Companyname runs together; too loose, and Comp any splits. If a tool gets this wrong for your files, switch to one that lets you tune it. pdfplumber's extract_text(x_tolerance=...) is the usual choice.

How to tell which case you have

  1. Try to select one word in a viewer. Nothing selects: it is a scan.
  2. Paste the selection into a text editor. Symbols instead of letters: the font has no map.
  3. Copy is greyed out in the menu: permissions.
  4. The paste is nearly right: ligatures or spacing.

For files you receive in bulk, do the same check in code, and send only the pages that need it to OCR, which is slow compared with reading text that is already there.

Questions

Why does copied PDF text turn into random symbols?

The PDF's fonts have no ToUnicode table, which maps each drawn shape to a letter. The viewer can draw the page but cannot say which letters are on it, so it pastes the shapes' numbers as if they were characters.

How do I fix a PDF that copies as gibberish?

Try a tool that reads the font when the table is missing: pdfminer.six and pdfplumber read our test file correctly where pypdf, PyMuPDF and pdftotext did not. If that fails, run OCR over the page with ocrmypdf --force-ocr.

Why can I copy text from some PDFs and not others?

PDFs exported from a program contain text. PDFs made by a scanner or a camera contain only pictures of pages, and there is nothing to copy until OCR adds a text layer.

Can I copy text from a PDF when copying is disabled?

The restriction is a permission set by the author, and viewers respect it. Ask the author for an unrestricted copy.

Try it on your own documents

A free plan every month, no credit card. See the PDF to text API.

Start free