<div dir="ltr"><div dir="ltr"><div>I have a pdf where each page is split into 2 columns. The text starts at the 1st column (on the left) and when that column is filled it continues to the 2nd column (on the right). Once the 2nd column is filled it starts at the 1st column of the next page.</div><div>Sometimes, at the top of each page there might be some text that is outside/above the columns and spans both of them.<br></div><div><br></div><div>I tried to get the text using Poppler::Page::text() with an empty rect, but the text is weirdly formatted/mixed between columns.</div><div>How do I fix this? How do I get a list of rects for the text areas? How do I identify the order the text is supposed to flow?<br></div><div><br></div><div>Or generally how am I supposed to extract text in a meaningful order?</div><div><br></div><div>Furthermore, at least on the first page, there seems to be some text at the beginning that doesn't appear in a pdf viewer.</div><div><br></div><div>pdftotext seems to output a mostly correct order of text, which is also correctly separated section by section. And correctly formatted. It even removes hyphens from hyphenated words at the end of line!!!<br></div><div>I tried to look at the source to figure out how it does it, but it seems that it uses undocumented internal APIs and not the APIs from the documented bindings.<br></div></div></div>