Skip to main content

Articles

Why does my PDF text come out garbled?

Why PDF text extraction sometimes returns garbled characters, and how to fix it.

By GistCite team, Product and engineering · For researchers and students, consultants and analysts

Published · Reviewed

Key takeaways

  • Garbled text usually means the PDF's text layer stores characters in a font-specific order, not reading order.
  • A scanned page has no text layer at all, so plain extraction returns nothing to garble.
  • Layout-aware Markdown extraction rebuilds heading, paragraph order and tables instead of a raw character stream.
  • A scanned or photographed page needs OCR, priced per page, before it has any usable text.

What 'garbled' usually means

Most garbled PDF text comes from the way the file's internal text layer stores characters: in the order the printer or font laid them out, not necessarily left-to-right reading order. A plain extraction that reads that layer literally can return jumbled words, missing spaces, or a table collapsed into one run of numbers.

This is more common with PDFs generated by older software or converted from another format, where the internal character mapping was never quite aligned with the visible page.

When there is no text at all

A scanned page or a photographed document has no text layer to read in the first place. Plain extraction returns nothing for those pages, which can look like garbling but is really an empty result.

It is easy to mistake this for a bug, since the file opens and displays fine visually; the text layer is simply missing, not broken.

How layout-aware extraction helps

Document Extractor's Markdown conversion, built with Docling, rebuilds reading order, headings and tables instead of reading the raw character stream, and adds a page anchor before every page so the result stays traceable to the original.

It also keeps a table's rows and columns aligned instead of flattening them into a single run of numbers, which is usually where plain extraction does the most damage.

When you need OCR

If the page is a scan or a photo, OCR has to run first, at 3 units a page on Pro and API, to give the page any text at all before layout-aware extraction can organize it.

Running OCR first and then the layout-aware pass on the result gives a scanned document the same page anchors and heading structure as a digital one, once the text itself has been recognized.

References

The tools this article uses

Document Extractor

Extract clean text and LLM-ready Markdown from PDF, DOCX, PPTX, XLSX, TXT, EPUB and HTML, with OCR for scans, then export in nine formats.

About Document Extractor

Put it into practice

The step this article describes is one action in the toolkit.