# Import necessary modules from pypdf library from pypdf import PdfReader # Create a PdfReader object to read the PDF file reader = PdfReader("documentprocessing.pdf") # Iterate through all pages in the PDF for page in reader.pages: # Check if the page contains annotations ("/Annots" key) if "/Annots" in page: # Iterate through each annotation on the page for annot in page["/Annots"]: # Get the annotation object obj = annot.get_object() # Extract relevant information from the annotation object # - "subtype" represents the type of annotation (e.g., text, link) # - "location" represents the rectangle coordinates of the annotation annotation = {"subtype": obj["/Subtype"], "location": obj["/Rect"]} # Print the extracted annotation information print(annotation)