Reading order
How prasasti puts the text of a PDF page back in the order a person reads it.
A PDF doesn't store text in reading order. It stores drawing commands: put these letters at this spot, then those letters at that spot. The order of the commands is whatever the program that made the file chose. prasasti ignores that order and rebuilds it from where the text sits on the page.
doc = prasasti.Document("two-column-paper.pdf")
print(doc.page_text(0)) # the left column, then the rightLines
Letters that share a baseline form a line. Within a line, a gap wider than about the font size splits it into segments, so two columns that happen to share a baseline don't run together.
Two columns
Segments are then ordered by cutting the page into regions. A vertical cut is only taken where both sides look like real columns: wide segments, stacked over several lines. So a two-column article reads the whole left column, then the whole right one.
Tables
The same rule keeps tables together. Table cells are narrow and sit side by side, so they don't look like columns and no vertical cut goes through them. Each row comes back as one line, with its cells in order from left to right.
Text stored out of order
Some files write the bottom of the page first, or draw each line in a shuffled order. Since prasasti orders by position on the page and never by position in the file, the result reads top to bottom either way.
Words without spaces
Some programs place every word on its own and never write a space character. prasasti puts the spaces back by comparing the gap between two words with the width of a space in that font.
How well it works
On the six test files of the benchmark (plain prose, Unicode, two columns, tables, words without spaces and shuffled lines) prasasti gets every word in the right order.