Skip to content
Discussion options

You must be logged in to vote

Well, I don't know what happens in detail on your side, but this is my approach, which works just fine:

>>> import fitz
>>> doc=fitz.open("v110-changes.pdf")
>>> page=doc[0]
>>> rl1 = page.search_for("pixmaps coming from")
>>> len(rl1)
1
>>> A = rl1[0].tl
>>> rl2=page.search_for("needs to be checked.")
>>> len(rl2)
1
>>> B = rl2[0].br
>>> page.add_highlight_annot(start=A, stop=B)
'Highlight' annotation on page 0 of v110-changes.pdf
>>> doc.ez_save("x.pdf")
>>> 

Before:

After:

Replies: 8 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

Comment options

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

Answer selected by JorjMcKie
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #1445 on December 13, 2021 09:39.