Extract annotations from document page

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-parser -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-parser/parser-net-mcp:latest
Folders, licensing and more →

get_annotations(page_index) returns the annotations of one page (or slide) only. Page indexes start at 0.

Extract annotations from a specific page

from groupdocs.parser import Parser

with Parser("./reviewed.pdf") as parser:
    # Extract annotations from the first page (page indexes start at 0)
    annotations = parser.get_annotations(0)

    if annotations is None:
        print("Annotation extraction isn't supported for this format")
    else:
        print("Page 1: %d annotations" % len(annotations))
        for annotation in annotations:
            print("  [%s] %s" % (annotation.annotation_type, annotation.value))

The following sample file is used in this example: reviewed.pdf

Page 1: 2 annotations
  [Text] Check the 2,400 kg against last season's sell-through before we sign.
  [Highlight] Release date works for the Q4 cash forecast.

Download full output

Expected behavior: For the sample, prints:

Page 1: 2 annotations
  [Text] Approve the hero crop before the print run.
  [Link] Aurora Visuals portfolio

Extract annotations page by page

Use get_document_info().page_count to walk every page:

from groupdocs.parser import Parser

with Parser("./reviewed.pdf") as parser:
    if not parser.features.annotations:
        print("Annotation extraction isn't supported for this format")
    else:
        page_count = parser.get_document_info().page_count
        for page_index in range(page_count):
            annotations = parser.get_annotations(page_index)
            print("Page %d of %d: %d annotations" % (page_index + 1, page_count, len(annotations)))
            for annotation in annotations:
                print("  %s: %s" % (annotation.author_name or "(no author)", annotation.value))

The following sample file is used in this example: reviewed.pdf

Page 1 of 2: 2 annotations
  Lena Park: Check the 2,400 kg against last season's sell-through before we sign.
  Amara Osei: Release date works for the Q4 cash forecast.
Page 2 of 2: 2 annotations
  Amara Osei: Ask Northwind for the green coffee index they will use.
  Lena Park: Dock 2 is reserved for these two mornings.

Download full output

Expected behavior: For the two-page sample, prints:

Page 1 of 2: 2 annotations
  Tomas Reyes: Approve the hero crop before the print run.
  (no author): Aurora Visuals portfolio
Page 2 of 2: 0 annotations

Notes

  • A page without annotations gives an empty list, not None.
  • Every AnnotationItem also carries its own page_index, so get_annotations() followed by grouping on page_index gives the same result in one call.