PDFdesk

Blog · 2026-06-24 · 4 min

Extracted text is text, not layout

A PDF stores where each piece of text was drawn, not what order it should be read in. That is why extraction sometimes comes out scrambled.

Extract the text from a two-column article and you may get the first line of column one, then the first line of column two, then the second line of column one. The words are all correct. The order is nonsense.

This is not a bug in the extractor. It is a consequence of what a PDF stores.

A page is a set of placements

PDF records that a run of characters was drawn at a particular position, in a particular font, at a particular size. It does not record that this run is a heading, that one is a footnote, or that the page has two columns which should be read down and then across.

The reading order is something a human infers from layout. The file has no opinion about it.

What that means in practice

  • Columns interleave, because the extractor is working through drawing operations, and the document was written across the page.
  • Headers and footers land mid-text, appearing wherever they were drawn rather than at a sensible boundary.
  • Tables lose their shape. A table is lines and text positioned to look like a grid. Extraction gives you the cell contents in drawing order with nothing to say which row or column they belonged to.
  • Hyphenation persists. A word broken across a line break is two runs, and it stays broken.
  • Spaces are inferred. PDFs frequently do not store spaces; they store positioned runs, and the extractor decides where a gap is wide enough to be a space. Sometimes it guesses wrong in both directions.

Tagged PDFs, and why you rarely have one

PDF does support structure — a tagged document records headings, paragraphs, table cells and reading order, and it is what makes a document properly accessible.

Producing it requires the authoring tool to do the work, and many do not, or do it badly. Most documents in circulation are untagged, which is also the reason screen-reader support for PDFs is so uneven.

Getting usable output

  • Per-page extraction rather than one blob. It keeps at least the page boundaries, which are the one structural fact always available.
  • Expect to clean up. Extracted text is a starting point for a search index or a rough read, not a faithful reproduction.
  • Single-column documents extract well. Reports, letters and contracts usually come out close to correct. Save the low expectations for anything designed.
  • If there is no text at all, the document is a scan and needs OCR. Which produces a *different* kind of imperfect text — recognised rather than misordered — with its own failure modes.

The useful mental model: extraction tells you what words are on a page. It does not tell you what the page said.

Tools this is about