commit 3494eadf44752c8796f1a3e6ed3fd0b4feca8fd2 parent f7ad234e5564cb0dd850cf1faaae1fe4549fa4b9 Author: Antoine Amarilli <a3nm@a3nm.net> Date: Fri, 27 Dec 2024 16:38:26 +0100 pdfannot Diffstat:
pdfannot | | | 27 | +++++++++++++++++++++++++++ |
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/pdfannot b/pdfannot @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# https://stackoverflow.com/a/72642245 + +import popplerqt5 +import argparse + + +def extract(fn): + doc = popplerqt5.Poppler.Document.load(fn) + annotations = [] + for i in range(doc.numPages()): + page = doc.page(i) + for annot in page.annotations(): + contents = annot.contents() + if contents: + annotations.append(contents) + print(f'page={i + 1} {contents}') + + print(f'{len(annotations)} annotation(s) found') + return annotations + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('fn') + args = parser.parse_args() + extract(args.fn)