Last active
March 26, 2021 07:45
-
-
Save groupdocs-cloud-gists/33056f4d882ac79475738cb5872cd58c to your computer and use it in GitHub Desktop.
Extract or Remove Annotations from Word documents using a REST API on the cloud in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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\\") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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