Skip to content

Replace text #1674

Apr 12, 2022 · 9 comments · 19 replies
Discussion options

You must be logged in to vote

If you use get_text("words",sort=True) you don't need search!

nombre = "Emilio Jose Martí Gómez"
nombre_t = nombre.split(" ")
lnombre = len(nombre_t)  # number of name components
words = page.get_text("words", sort=True)
i = 0
while i < len(words):
    word = words[i]
    if word[4] == nombre_t[0]:  # found 1st part of name
        rects = [fitz.Rect(w[:4]) for w in words[i : i+lnombre]]
        # rects = list of rectangles containing the full name
        # process them adequately, then ...
        i += lnombre
    else:
        i += 1

Replies: 9 comments 19 replies

Comment options

You must be logged in to vote
1 reply
@mameIIas
Comment options

Comment options

You must be logged in to vote
1 reply
@mameIIas
Comment options

Comment options

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

@JorjMcKie
Comment options

Comment options

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

@mameIIas
Comment options

Comment options

You must be logged in to vote
1 reply
@mameIIas
Comment options

Comment options

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

@mameIIas
Comment options

Comment options

You must be logged in to vote
1 reply
@mameIIas
Comment options

Answer selected by JorjMcKie
Comment options

You must be logged in to vote
3 replies
@mameIIas
Comment options

@JorjMcKie
Comment options

@mameIIas
Comment options

Comment options

You must be logged in to vote
6 replies
@mameIIas
Comment options

@JorjMcKie
Comment options

@mameIIas
Comment options

@JorjMcKie
Comment options

@mameIIas
Comment options

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