Last active
April 9, 2021 06:04
-
-
Save groupdocs-cloud-gists/345608722b5699d01d69ee93e822ad11 to your computer and use it in GitHub Desktop.
Accept or Reject Tracked Changes of Word Document 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
Accept or Reject Tracked Changes using Python | |
1. Programmatically upload DOCX file on the cloud | |
2. Accept or Reject Tracked Changes 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
# Create an instance of the API | |
api_instance = groupdocs_comparison_cloud.ReviewApi.from_keys(client_id, client_secret) | |
# Set source file | |
source = groupdocs_comparison_cloud.FileInfo() | |
source.file_path = "source_with_revs.docx" | |
options = groupdocs_comparison_cloud.ApplyRevisionsOptions() | |
options.source_file = source | |
options.output_path = "output/result.docx" | |
request = groupdocs_comparison_cloud.GetRevisionsRequest(options) | |
revisions = api_instance.get_revisions(request) | |
# Get all revisions count | |
print("Revisions count: " + str(len(revisions))) | |
# Accept revisions | |
for revision in revisions: | |
revision.action = "Accept" | |
options.revisions = revisions | |
request = groupdocs_comparison_cloud.ApplyRevisionsRequest(options) | |
response = api_instance.apply_revisions(request) |
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
# Create an instance of the API | |
api_instance = groupdocs_comparison_cloud.ReviewApi.from_keys(client_id, client_secret) | |
# Set source file | |
source = groupdocs_comparison_cloud.FileInfo() | |
source.file_path = "source_with_revs.docx" | |
options = groupdocs_comparison_cloud.ApplyRevisionsOptions() | |
options.source_file = source | |
options.output_path = "output/result.docx" | |
# Accept all revisions | |
options.accept_all = True | |
request = groupdocs_comparison_cloud.ApplyRevisionsRequest(options) | |
response = api_instance.apply_revisions(request) |
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 = "112f0f38-9dae-42d5-b4fc-cc84ae644972" | |
client_secret = "16ad3fe0bdc39c910f57d2fd48a5d618" | |
configuration = groupdocs_comparison_cloud.Configuration(client_id, client_secret) | |
configuration.api_base_url = "https://api.groupdocs.cloud" | |
my_storage = "" |
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 initialization | |
file_api = groupdocs_comparison_cloud.FileApi.from_config(configuration) | |
request = groupdocs_comparison_cloud.DownloadFileRequest("output\\result.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
# Create an instance of the API | |
file_api = groupdocs_comparison_cloud.FileApi.from_config(configuration) | |
request = groupdocs_comparison_cloud.UploadFileRequest("source_with_revs.docx", "C:\\Files\\source_with_revs.docx", "") | |
response = file_api.upload_file(request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment