Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extract or Remove Annotations from Word documents using a REST API on the cloud in Python
Extract or Remove Annotations from Word documents using Python
1. Programmatically upload DOCX file on the cloud
2. Extract Annotations from uploaded DOCX File programmatically using Python.
3. Remove Annotations from uploaded DOCX File programmatically using Python.
3. Download the output files from the cloud.
client_id = "da0c487d-c1c0-45ae-b7bf-43eaf53c5ad5"
client_secret = "479db2b01dcb93a3d4d20efb16dea971"
configuration = groupdocs_annotation_cloud.Configuration(client_id, client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"
# api instance
file_api = groupdocs_annotation_cloud.FileApi.from_config(configuration)
# download file request
request = groupdocs_annotation_cloud.DownloadFileRequest("output.docx", my_storage)
response = file_api.download_file(request)
# Move downloaded file to your working directory
shutil.move(response, "C:\\Files\\")
# api instance
api = groupdocs_annotation_cloud.AnnotateApi.from_config(configuration)
# input file details
file_info = groupdocs_annotation_cloud.FileInfo()
file_info.file_path = "input.docx"
# extract annotation request
request = groupdocs_annotation_cloud.ExtractRequest(file_info)
result = api.extract(request)
print("ExtractAnnotations: annotations count: " + str(len(result)))
# api instance
api = groupdocs_annotation_cloud.AnnotateApi.from_keys(client_id, client_secret)
# input file details
file_info = groupdocs_annotation_cloud.FileInfo()
file_info.file_path = "input.docx"
# remove options
options = groupdocs_annotation_cloud.RemoveOptions()
options.file_info = file_info
options.annotation_ids = [0,1,2,3,4,5,6,7,8,9,10,11]
# output file
options.output_path = "output.docx"
# remove request
request = groupdocs_annotation_cloud.RemoveAnnotationsRequest(options)
result = api.remove_annotations(request)
print("RemoveAnnotations: Annotations removed: " + result['href'])
# api instance
file_api = groupdocs_annotation_cloud.FileApi.from_config(configuration)
# upload file
request = groupdocs_annotation_cloud.UploadFileRequest("input.docx", "C:\\Files\\input.docx", my_storage)
response = file_api.upload_file(request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment