Tutorial: Applying Revisions with ApplyRevisionsOptions
In this tutorial, you’ll learn how to use the ApplyRevisionsOptions data structure in GroupDocs.Comparison Cloud API to programmatically apply or reject revisions in documents. This is particularly useful for automating document review workflows and managing tracked changes.
Learning Objectives
- Understand the ApplyRevisionsOptions structure and its components
- Learn how to retrieve revision information from documents
- Implement selective acceptance or rejection of revisions
- Create efficient document revision workflows
- Save documents with processed revisions
Prerequisites
- GroupDocs.Comparison Cloud API credentials
- Advanced understanding of document revision concepts
- Familiarity with track changes in word processing documents
- Test documents with revisions for practice
Understanding the ApplyRevisionsOptions Structure
The ApplyRevisionsOptions data structure defines options for applying revisions using the “PUT” /comparison/revisions API method. It allows you to specify which revisions to accept or reject in a document.
{
'SourceFile': {
'FilePath': 'source_files/word/source_with_revs.docx'
},
'Revisions': [
{
'Id': 0,
'action': 'Accept'
},
{
'Id': 1,
'action': 'Accept'
},
],
'OutputPath': 'output/result.docx'
}
Key components include:
Component | Description |
---|---|
SourceFile | Information about the source file (using the FileInfo structure) |
Revisions | Array of revision settings (using the RevisionInfo structure) |
OutputPath | Path to the output document |
Implementing ApplyRevisionsOptions in Your Application
Step 1: Retrieving Revision Information
Before you can apply revisions, you need to know what revisions exist in the document:
Try it yourself
Retrieve the revision information from a document with tracked changes and examine the structure of the results.
Step 2: Creating a Basic Revision Application Configuration
Now, let’s create a basic configuration to apply some revisions:
Step 3: Selectively Accepting and Rejecting Revisions
In real-world scenarios, you’ll often want to selectively accept or reject revisions based on certain criteria:
Troubleshooting Tip
If revisions aren’t being applied as expected, verify that you’re using the correct revision IDs and that the action values are correctly spelled (“Accept” or “Reject”). The API is case-sensitive.
Step 4: Handling Different Types of Revisions
Different types of revisions (insertions, deletions, formatting changes) may require different handling:
Step 5: Creating a Complete Revision Application Workflow
Finally, let’s put everything together for a comprehensive revision application workflow:
Implementing Revision Strategies
Let’s explore some common revision management strategies:
Author-Based Revision Management
Accept or reject revisions based on their authors:
Time-Based Revision Management
Process revisions based on when they were made:
Content-Based Revision Management
Make decisions based on the content of the revisions:
What You’ve Learned
In this tutorial, you’ve learned:
- How to configure the ApplyRevisionsOptions structure for processing document revisions
- How to retrieve revision information from documents
- How to selectively accept or reject revisions
- How to implement different revision management strategies
- How to create complete revision processing workflows
Further Practice
Try these exercises to reinforce your learning:
- Create a revision management system that follows specific rules (e.g., accept all formatting changes but review content changes)
- Build a batch processing system that applies the same revision rules to multiple documents
- Implement a revision audit system that logs all revision decisions