Two-column PDFs make AI lie politely

Here is a quiet way to publish nonsense. Take a case study laid out in two columns, extract the text, and ask a model to turn it into a web page. You will get a clean, confident page. It may have very little to do with the document.

How the text gets scrambled

A common PDF extractor reads strictly from the top of the page to the bottom. On a two-column page that means one line from the left, one line from the right, and back again. What comes out is two arguments shuffled together, line by line.

The trouble is that it still looks like prose. Each fragment is grammatical. Nothing is flagged as broken. A language model is very good at smoothing fragments into sentences, so it does, and the polish hides the damage. The output reads better than the input, which is exactly why nobody goes back to check.

Reading order will fool you too

On the document I tested, the right column started four points higher on the page than the left. The extractor emitted the right column first. A careful reconstruction by hand put the columns in the wrong order, and that version read plausibly as well.

The only dependable evidence is position. Each word in the file has coordinates, and the horizontal one tells you which column it belongs to.

The method I use is simple to describe:

  1. Project the position of every word onto the horizontal axis.
  2. Look for empty gaps wide enough to be a gutter, ignoring the page margins.
  3. Assign each word to a column by its horizontal midpoint.
  4. Inside each column, group words into lines from top to bottom.

If a full-width heading bridges the gutter and hides it, try again using only the words below the top of the page. This has been checked against one document so far. Three-column and mixed layouts are still untested, so I look at the page as well.

Numbers are worse

Pages of large figures fall apart completely. One results page extracted as a pile of separate digits and percent signs, with no way to put them back together. Read statistics from the picture of the page, never from the text layer. If a figure is going on your website, someone should be able to point at it in the original.

Before you feed a PDF to a model

  • Look at the page. If it has columns, assume plain extraction will scramble it.
  • Compare a paragraph of extracted text with the same paragraph on the page.
  • Check the page count with a tool. Files described to me as 40 and 62 pages turned out to be 7 and 1.
  • Expect the content to be in the images. The case study I tested had 13 images and fewer than 3,000 characters of text across 7 pages.

None of this is the model's fault. It was handed scrambled text and asked to be helpful. The check has to happen before it starts writing.

All production notes