How Do I Preserve Reading Order in Multi-Column PDFs?
Document AI

How Do I Preserve Reading Order in Multi-Column PDFs?

DocuShell TeamJuly 6, 20267 min read

Diagnose the actual reading-order failure

Preserve reading order in a multi-column PDF by using layout-aware parsing that groups text into regions before sequencing those regions. The parser should detect columns, headings, sidebars, captions, and tables instead of reading every text object by its internal file order.

That distinction decides whether an extracted report reads like a report or like shuffled notes.

Region types need different sequencing rules

Page region Typical reading rule Common extraction mistake
Main columns Finish one column before the next Alternating lines across columns
Full-width heading Read before the columns below Attached only to the left column
Sidebar Keep separate unless referenced Inserted mid-paragraph
Figure caption Bind to its figure Moved into body copy
Footnote Link to marker and page Appended to an unrelated sentence
Continued table Preserve header and row order Read across columns as prose

Why PDFs scramble text

A PDF describes where characters appear. It does not have to describe the order in which a person reads them. Two columns may be stored line by line, object by object, or in the order they were added by the publishing software.

Raw extraction can produce a sentence from the left column, jump to the right column, then return to the left. Footnotes and running headers can land in the middle of body copy.

Use layout regions before sequence

A layout-aware parser first identifies blocks and their coordinates. It can then infer columns and build a reading sequence within each region.

DocuShell Parse PDF uses structured, layout-aware processing for dense reports and multi-column documents. Its output can retain page and bounding-box context for review and downstream citations.

Gotcha: sorting every text block by top coordinate and then left coordinate is not layout analysis. On a two-column page, it often produces line-by-line ping-pong between columns.

A simplified layout pass works in this order:

  1. Detect page-wide headings and separators.
  2. Partition the remaining page into column or region groups.
  3. Order blocks inside each region.
  4. Attach captions, notes, and footnotes to their owners.
  5. Emit the final sequence while retaining every source box.

The following TypeScript is deliberately conceptual. It shows why region detection must happen before block sorting; production layout analysis needs stronger geometry and document-type tests.

type Block = {
  id: string;
  text: string;
  bbox: [number, number, number, number];
  kind: "heading" | "paragraph" | "caption" | "footnote";
};

function buildReadingOrder(blocks: Block[]): Block[] {
  const pageWide = blocks.filter(isPageWideHeading).sort(topToBottom);
  const remaining = blocks.filter(block => !pageWide.includes(block));
  const regions = detectColumnRegions(remaining).sort(leftToRight);

  const orderedBody = regions.flatMap(region =>
    region.blocks.sort(topToBottom)
  );

  return attachCaptionsAndFootnotes([...pageWide, ...orderedBody]);
}

Use this pattern as an acceptance-test target, not as a drop-in replacement for a layout engine.

Treat special regions differently

Not every block belongs in the main flow:

  • Running headers and footers should usually be removed or stored once.
  • Sidebars should remain separate unless the body explicitly refers to them.
  • Captions should stay with their figure or table.
  • Footnotes need a link to the sentence or page they qualify.
  • Tables should remain intact instead of being read across rows as prose.

This is why one global top-to-bottom sort is not enough.

Check the result in Markdown

Markdown is a useful QA format because structural errors are visible. Headings, paragraphs, lists, and tables can be read quickly without opening a developer console.

Compare representative pages with the source. Focus on the first column break, pages with sidebars, and pages where a table continues. If those work, routine pages usually follow.

Preserve coordinates for disagreements

Reading-order algorithms make inferences. Keep page and coordinate metadata so a reviewer can resolve ambiguous layouts and so a RAG answer can point back to the exact region.

Clean text is useful. Clean text with a route back to the page is much easier to trust.

Example: a two-column research report

Imagine a page with body text in two columns, a chart across the bottom, and a footnote below it. Sorting every text box by vertical position reads the first line of the left column, then the first line of the right column. The result alternates between two unrelated arguments.

A layout-aware flow first detects the left and right column regions. It reads the left column top to bottom, then the right column, links the chart caption to the chart, and stores the footnote separately. The visible page determines the sequence, not the order of objects inside the PDF file.

Signals that reading order is broken

Look for sentence fragments, headings followed by unrelated text, duplicated running headers, captions far from their figures, and numbered lists that jump backward. Sudden topic changes in the parsed Markdown are often a layout problem rather than bad writing.

Create a small golden set with newsletters, academic papers, annual reports, and manuals. Compare element order, not only extracted character count. A parser can recover every word and still produce unusable reading order.

What to retain for downstream repair

Keep each block's page, bounding box, detected type, and sequence index. If a reviewer corrects the order, store that correction as a transformation rather than rewriting the source record.

The structured JSON and page-coordinate guide explains the geometry. For retrieval, follow PDF chunking without lost citations. If OCR is involved, the OCR accuracy preparation guide helps reduce errors before layout reconstruction begins.

Frequently Asked Questions

PDF text is positioned on a canvas and may not include a reliable reading sequence. Simple extractors often follow internal object order instead of visual layout.
OCR can recover text from images, but layout analysis is still needed to decide which block comes next. Character recognition and reading-order reconstruction are separate problems.
Compare the parsed Markdown with the original page, especially around column breaks, sidebars, tables, and footnotes. Test element sequence rather than relying only on recovered character count.

Free Tool

PDF to JSON

Turn PDFs into structured, source-aware data for RAG, review, and automation.

Try PDF to JSON
pdf reading ordermulti column pdf extractionlayout aware pdf parserxy cutpdf to markdown
D

DocuShell Team

The DocuShell editorial group writes and maintains guides for everyday PDF workflows, with updates made when tool behavior or documented limits change. See our editorial standards for the process behind each article.

Focus: Layout-aware PDF parsing and structured document extraction

Questions or feedback? Get in touch.

Related Articles