Fetch annotations with annotated element #1163
-
Hey! I am doing decomposition of PDF document. I've done decomposition of the PDF successfully but, Now I want to fetch all annotations mapped with the elements on which they are annotated on. For eg: In this example, I've a paragraph on which annotations "Paragraph" is annotated. I want to fetch "Paragraph" annotation with the whole paragraph mapped with it. I've tried " .annots() " But i didn't got the desired output: #code:
#output:
Thanks in Advance, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Don't understand yet:
What would be the desired output? The page text covered by the annot rectangle? |
Beta Was this translation helpful? Give feedback.
-
Would this be it: >>> for a in page.annots():
print("Annot: %s, text: '%s'" % (a.info["content"], page.get_textbox(a.rect)))
Annot: Heading 1, text: ''
Annot: Heading 2, text: ''
Annot: Paragraph, text: '1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also
the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. '
Annot: Reference Link, text: ''
Annot: Heading 2, text: ''
Annot: Paragraph, text: 'quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. '
Annot: Heading 3, text: ''
Annot: Paragraph, text: 'inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,
sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet,
consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad
minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? '
Annot: Heading 4, text: ''
Annot: Paragraph, text: 'system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids
pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are
extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally
circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious
physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no
annoying consequences, or one who avoids a pain that produces no resultant pleasure?" '
Annot: Table, text: ''
>>> |
Beta Was this translation helpful? Give feedback.
-
Sure, why not |
Beta Was this translation helpful? Give feedback.
Sure, why not