pub enum ReadingOrder {
TopToBottom,
ColumnAware,
Structure,
}Expand description
Reading order mode for span extraction.
Controls how text spans are sorted after extraction from a PDF page.
The default TopToBottom mode uses simple geometric sorting, while
ColumnAware uses the XY-Cut algorithm to detect columns and read
each column top-to-bottom before moving to the next.
Variants§
TopToBottom
Simple top-to-bottom, left-to-right ordering.
Sorts spans by Y-coordinate descending (top of page first), then by X-coordinate ascending (left to right).
ColumnAware
Column-aware ordering using the XY-Cut algorithm.
Detects columns via projection-profile analysis and reads each column fully (top-to-bottom) before moving to the next column. Best for newspapers, academic papers, and multi-column layouts.
Structure
Logical-structure ordering from the document’s /StructTreeRoot.
For a Tagged PDF, ISO 32000-1:2008 §14.8.2.3 makes a pre-order traversal of the structure hierarchy AUTHORITATIVE for reading order - it is the producer’s declared sequence, independent of glyph geometry, so it reads tables and complex layouts correctly where a geometric XY-cut guesses.
Spans are ordered by their marked-content id (/MCID) following that
traversal; any span without a matching MCID is appended in geometric
(ColumnAware) order. When the structure tree is absent or not
trustworthy for ordering (untagged, or /Suspects true), this falls back
to ColumnAware entirely, so it is always safe to request.