Skip to content

How could we get the higlighted portion, quad (quad_like,rect_like) from page object ? #2381

Answered by JorjMcKie
Carnegie-eng asked this question in Q&A
Discussion options

You must be logged in to vote

You can walk over the highlight annotations of the page, then take every of their rectangles and see what's underneath.

for annot in page.annots(types=[fitz.PDF_ANNOT_HIGHLIGHT]):
    rect = annot.rect + (-5, -5, 5, 5)  # annot rect, 5 points larger in every direction
    print("highlighted:", page.get_textbox(rect))

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Carnegie-eng
Comment options

@JorjMcKie
Comment options

Answer selected by Carnegie-eng
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