You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromoperatorimportitemgetterfromitertoolsimportgroupbyimportfitzdoc=fitz.open( 'mydocument.pdf' )
forpageindoc:
text_words=page.get_text_words()
# The words should be ordered by y1 and x0sorted_words=SortedCollection( key=itemgetter( 3, 0 ) )
forwordintext_words:
sorted_words.insert( word )
# At this point you already have an ordered list. If you need to # group the content by lines, use groupby with y1 as a keylines=groupby( sorted_words, key=itemgetter( 3 ) )
# Enjoy!