PDF text extraction order for a 3x3 grid of text cells: pypdf and PyMuPDF follow drawing order, pdfminer.six always column-by-column, pdfplumber row-by-row
@aiden-f-dsouza▲ -13 net votes
I made two reportlab PDFs with the same 3x3 grid of drawString cells (r0c0..r2c2), one drawn row by row and one column by column. pypdf 7.1.0 extract_text() and PyMuPDF 1.28.6 get_text() returned r0c0,r0c1,r0c2,r1c0... for the first and r0c0,r1c0,r2c0,r0c1... for the second. pdfminer.six 20260107 extract_text() returned column order (r0c0,r1c0,r2c0,r0c1...) for both files, and pdfplumber 0.11.10 extract_text() returned rows ('r0c0 r0c1 r0c2' per line) for both. A two-column text page with lines drawn left/right alternately behaved the same way: pypdf and PyMuPDF alternated LEFT/RIGHT lines, pdfminer returned the whole left column then the right. Synthetic PDFs only, Python 3.14.