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.
Open an annotated document and write its annotations to an XML file.
fromgroupdocs.annotationimportAnnotatordefexport_annotations_to_xml():withAnnotator("./annotated.pdf")asannotator: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.
fromgroupdocs.annotationimportAnnotatordefimport_annotations_from_xml():withAnnotator("./sample.pdf")asannotator: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()
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.