How to Fix Garbled or Scrambled Text in a PDF File

How to Fix Garbled or Scrambled Text in a PDF File

Garbled PDF text is a missing character map, not corruption. How to tell which problem you have, what actually fixes it, and what will not work.

Text that looks fine on screen but pastes as "&#$%@" — or as empty boxes, or as nothing at all — is not corruption. The page is drawing the right shapes; what is missing is the mapping that says which character each shape represents. Knowing that narrows the fix considerably.

Why it happens

A PDF does not store "the letter A". It stores an instruction to draw glyph number 36 from an embedded font. A separate table — the ToUnicode CMap — records that glyph 36 means U+0041, the letter A.

Copy, search and screen readers all depend on that table. Rendering does not. So when the CMap is missing, wrong, or built from a subset font that was re-indexed during export, the page looks perfect and the text underneath is gibberish.

Three specific causes account for most of it:

  1. No ToUnicode table at all. Common in PDFs produced by older LaTeX toolchains, some CAD exporters, and cheap print drivers.
  2. A subsetted font with re-indexed glyphs. The exporter kept only the glyphs used and renumbered them, without updating the mapping.
  3. A symbolic font. Wingdings, custom icon fonts and many maths fonts map glyphs to codes that are meaningless as Unicode by design.

Work out which problem you have

This takes thirty seconds and decides everything that follows.

Select a line of body text with your cursor.

  • Nothing highlights — there is no text layer. This is a scanned image, and no amount of fixing the CMap will help; you need OCR.
  • It highlights, and pastes correctly — the file is fine. Your problem is the program you pasted into, or a missing font on the receiving machine.
  • It highlights, but pastes as nonsense — a broken ToUnicode mapping. This is the case the rest of this covers.
  • Only some of it is wrong — usually one font among several is broken. Often headings are fine and body text is not, or vice versa.

What actually fixes it

Be realistic about this: a broken mapping is missing information, and no tool can reliably invent it. The practical routes, best first:

Get a better source file. If the PDF was exported from Word, InDesign or LaTeX, re-export it with fonts fully embedded rather than subsetted. This is the only fix that is genuinely clean, and it is worth one email to whoever produced the file.

Re-print to PDF from a viewer. Open the file and print to PDF from a different application. Some viewers rebuild the text layer with a correct mapping. It works often enough to be worth ninety seconds, and it costs nothing to try.

OCR the page as an image. If the mapping cannot be recovered, ignore the broken text layer and read the pixels instead. OCR the page and you get text derived from the glyph shapes — which is what you could see all along. Accuracy depends on the scan quality and the font, and you will need to proofread it. This site's editor does not do OCR, so use a dedicated OCR tool for this step.

Retype it. For a paragraph or two this is faster than everything above and is guaranteed correct.

Things that will not work

Changing the font in an editor. The mapping is the problem, not the typeface. Restyling the text does not create the missing information.

Copying into a different program. Word, Notepad and your email client all read the same broken table. The gibberish follows.

Saving as .txt. Same table, same result.

Repair tools. Most "PDF repair" utilities fix structural damage — broken cross-reference tables, truncated files. A file with an intact structure and a missing CMap is not damaged in the way they fix.

If you only need to change what is on the page

Sometimes you do not need to extract the text at all — you need to correct a figure or a name and send it on. Editing the visible content is a different job from recovering the text layer, and it usually still works: this site's editor lets you change text in place while keeping the layout, on files up to 10 MB and 100 pages.

Do check the result carefully. On a file with a broken mapping, what you type and what you see can diverge in unhelpful ways, so proofread the edited region on screen before you send it.

Frequently asked questions

Why does it look fine but paste as gibberish? Drawing and copying use different information. The glyph shapes are intact; the table that maps them to characters is not.

Is my file corrupted? Almost certainly not. It opens, renders and prints. It is missing metadata, not damaged.

Will OCR fix it? It sidesteps it. OCR reads the picture of the page and produces new text, ignoring the broken layer. Expect to proofread.

Only the headings are wrong. Why? Headings usually use a different font from body text, and only that font's mapping is broken.

Can I stop this happening to files I create? Embed fonts fully rather than subsetting them when you export, and avoid symbolic fonts for anything that needs to be searchable.

Usama Ramzan
Written byUsama RamzanFounder, Online PDF Edits

Usama Ramzan is the founder of Online PDF Edits, a browser-based PDF editor built to change text, images, and tables in existing PDFs without breaking their fonts, spacing, or multi-page layout. He writes about practical PDF editing, document workflows, and the engineering behind layout-safe editing.

Recommended reading

View all articles →