-
Hello, can somebody explain me how i can get the Text which is highlighted in the PDF. I know, that i can get the annot Text with a loop over page.annot() / annot.getText. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
There is one thing you must keep in mind: But of course, highlight annotations (like their friends: underlines, strike-throughs, squiggles) are mostly used to mark text. So you might want to do this: for annot in page.annots(types=(fitz.PDF_ANNOT_HIGHLIGHT, fitz.PDF_ANNOT_UNDERLINE)):
print(page.get_text(clip=annot.rect)) The annotation method |
Beta Was this translation helpful? Give feedback.
-
BTW: your post is a typical Discussions item, not an issue. |
Beta Was this translation helpful? Give feedback.
-
Hi Jorj, Could you please help in provide details on how to create a FreeText Cllaout Annotation ? |
Beta Was this translation helpful? Give feedback.
-
I found something strange when dealing with extracting comments from PDF (made with Acrobat). |
Beta Was this translation helpful? Give feedback.
There is one thing you must keep in mind:
Annotations are not part of the page's contents. Imagine them like dust on a nice painting on the wall. The items shown in the painting are not aware of any dust that may cover them. And like dust, annotations can be wiped out without changing the page itself.
You get the idea.
Accordingly, an annotation may cover just anything: text, drawings, images ... or nothing.
There is a rectangle associated with an annotation,
annot.rect
, which can be used to find out what is underneath it. For example do this to find any covered text:text = page.get_text(clip=annot.rect)
.But of course, highlight annotations (like their friends: underlines, strike-throug…