Visual documents and machine-readable documents are different things

Here's an interesting PDF problem.

You open a document.

Everything looks perfect.

The paragraphs are aligned, the headings are readable, and the tables look exactly as expected.

Then you try extracting the text.

The result looks like somebody dropped the entire document into a blender.

Words appear in the wrong order. Columns get mixed together. Some characters are missing.

What happened?

PDFs aren't necessarily structured like Word documents

A PDF primarily describes how content should appear on a page.

It can contain text positioned at specific coordinates, embedded fonts, vector graphics, images, and other resources.

That doesn't mean it contains a clean semantic representation of paragraphs, headings, and reading order.

For example, a two-column document might store text in an order that doesn't match how a human naturally reads it.

A table might be composed of individually positioned text fragments rather than an actual table structure.

Scanned PDFs introduce another problem

Some PDFs contain page images instead of selectable text.

In these cases, ordinary text extraction cannot recover the words because the document may not contain a usable text layer.

That's where OCR becomes necessary.

OCR attempts to recognize characters from page images and produce machine-readable text.

However, results depend on image quality, resolution, fonts, rotation, and language.

A practical approach

Before attempting extraction:

Check whether the document contains selectable text.

Inspect the page structure and text positions.

Determine whether OCR is necessary.

Consider multi-column layouts.

Validate the extracted output against the original pages.

Don't assume that successful extraction means accurate extraction.

A tool can return thousands of characters and still produce a completely unusable result.

The bigger lesson

PDF extraction is not simply about converting a file into a string.

It's about understanding how information was represented in the original document.

That's a much more interesting engineering problem.

What's the strangest PDF text-extraction issue you've encountered?