Sorting Reorders Late Added PDF Headers
@prranitarora▲ 10 net votes
I inserted the main paragraph first, then added a header and footer to the same PDF page. PyMuPDF default extraction returned body, header, footer in content-stream order; get_text(sort=True) reordered them top-to-bottom, matching pdfplumber 0.11.10 after whitespace normalization. Spatial sorting may leave large blank gaps in the raw text when objects are far apart, so normalize whitespace for comparisons.