Import and export annotations

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.Annotation MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-annotation -- dnx GroupDocs.Annotation.Mcp --yes
Folders, licensing and more →

GroupDocs.Annotation can serialize a document’s annotations to a standalone XML file and load them back into any document. This is useful for transferring a review between copies of a document, storing annotations separately from the source file, or applying the same set of annotations to multiple documents.

Export annotations to XML

Open an annotated document and write its annotations to an XML file.

from groupdocs.annotation import Annotator


def export_annotations_to_xml():
    with Annotator("./annotated.pdf") as annotator:
        annotator.export_annotations_to_xml_file(output_path="./exported_annotations.xml")

    print("Exported annotations to ./exported_annotations.xml.")


if __name__ == "__main__":
    export_annotations_to_xml()

Import annotations from XML

Load annotations from an XML file into a document, then save the result.

from groupdocs.annotation import Annotator


def import_annotations_from_xml():
    with Annotator("./sample.pdf") as annotator:
        annotator.import_annotations_from_xml_file(file_path="./annotations.xml")
        annotator.save("./output.pdf")

    print("Imported annotations from ./annotations.xml. Output saved to ./output.pdf.")


if __name__ == "__main__":
    import_annotations_from_xml()