List comments/annotations in PDF
Adobe Reader can export and view a list of comments through the Comment tab on the right side. To do this from a command line program (for example to feed AI analysis / training) consider a Python script using the high performance PyMuPDF (fitz) library:
import fitz
import sys
file = sys.argv[1]
doc = fitz.open(file)
for i, page in enumerate(doc, start=1):
for a in page.annots() or []:
info: dict = a.info
print(
f"page {i} {a.type[1]} "
f"author={info.get('title')!r} "
f"text={info.get('content')!r}"
)
# for highlights, get the actual selected words:
if a.type[1] in ("Highlight", "Underline", "StrikeOut", "Squiggly"):
print(" quoted:", page.get_textbox(a.rect))