pdfannot (675B)
1 #!/usr/bin/env python3 2 # https://stackoverflow.com/a/72642245 3 4 import popplerqt5 5 import argparse 6 7 8 def extract(fn): 9 doc = popplerqt5.Poppler.Document.load(fn) 10 annotations = [] 11 for i in range(doc.numPages()): 12 page = doc.page(i) 13 for annot in page.annotations(): 14 contents = annot.contents() 15 if contents: 16 annotations.append(contents) 17 print(f'page={i + 1} {contents}') 18 19 print(f'{len(annotations)} annotation(s) found') 20 return annotations 21 22 23 if __name__ == '__main__': 24 parser = argparse.ArgumentParser() 25 parser.add_argument('fn') 26 args = parser.parse_args() 27 extract(args.fn)