Skip to content

page.get_text('words', myRect) versus page.search_for() #2860

Answered by JorjMcKie
sgthuth asked this question in Q&A
Discussion options

You must be logged in to vote

Looks ok to me:

In [1]: import fitz
In [2]: doc=fitz.open("T3683153_Preped.PDF")
In [3]: page=doc[0]
In [4]: page=doc[2]
In [5]: page.search_for("dps$$$PKG")
Out[5]: [Rect(72.0, 150.3087615966797, 130.6758575439453, 162.4904022216797)]
In [6]: [w for w in page.get_text("words") if w[4]=="DPS$$$PKG"]
Out[6]:
[(72.0,
  150.3087615966797,
  130.6758575439453,
  162.4904022216797,
  'DPS$$$PKG',
  2,
  0,
  0)]

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@sgthuth
Comment options

@JorjMcKie
Comment options

Answer selected by sgthuth
@sgthuth
Comment options

@JorjMcKie
Comment options

Comment options

You must be logged in to vote
2 replies
@sgthuth
Comment options

@JorjMcKie
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants