Tutorial: Creating Powerful Comparisons with ComparisonOptions
In this tutorial, you’ll learn how to use the ComparisonOptions data structure in GroupDocs.Comparison Cloud API to configure comprehensive document comparison operations. This structure brings together multiple configuration elements to give you complete control over the comparison process.
Learning Objectives
- Understand the ComparisonOptions structure and its components
- Configure source and target document references
- Implement detailed comparison settings
- Specify output paths and formats
- Create complete comparison operations for different document types
Prerequisites
- GroupDocs.Comparison Cloud API credentials
- Advanced understanding of document comparison concepts
- Familiarity with JSON structures
- Test documents for comparison operations
Understanding the ComparisonOptions Structure
The ComparisonOptions data structure defines a complete comparison operation, including source and target files, comparison settings, and output options.
{
"SourceFile": {
"FilePath": "string",
"VersionId": "string",
"StorageName": "string",
"Password": "string"
},
"TargetFiles": [
{
"FilePath": "string",
"VersionId": "string",
"StorageName": "string",
"Password": "string"
}
],
"Settings": {
"GenerateSummaryPage": true,
"ShowDeletedContent": true,
"ShowInsertedContent": true,
// ... additional settings ...
},
"ChangeType": "None",
"OutputPath": "string"
}
Key components include:
Component | Description |
---|---|
SourceFile | Information about the source file (using the FileInfo structure) |
TargetFiles | An array of information about target file(s) (using the FileInfo structure) |
Settings | Comparison process settings (using the Settings structure) |
ChangeType | Changes type (used only for Changes resource) |
OutputPath | Path to the resultant document |
Implementing ComparisonOptions in Your Application
Step 1: Creating a Basic Comparison Configuration
Let’s start with a basic configuration that compares two documents with default settings:
Try it yourself
Create a basic ComparisonOptions object and use it to compare two simple documents.
Step 2: Configuring Multiple Target Files
ComparisonOptions supports comparing one source file with multiple target files:
Step 3: Implementing Detailed Comparison Settings
Now let’s enhance our comparison with detailed settings:
Troubleshooting Tip
If your comparison results don’t match expectations, verify that the Settings configuration is appropriate for your document types. Different document formats may require specific settings for optimal results.
Step 4: Working with Password-Protected Documents
Many business documents are password-protected. Here’s how to handle them:
Step 5: Specifying Output Options
Control how and where the comparison result is saved:
Step 6: Creating a Complete Comparison Operation
Finally, let’s put everything together for a comprehensive comparison operation:
Best Practices for Different Comparison Scenarios
Document Review Workflow
For a document review workflow, prioritize visibility and tracking of changes:
Legal Document Comparison
For legal documents, precision and comprehensive detection are critical:
Visual Content Comparison
When comparing documents with significant visual content:
What You’ve Learned
In this tutorial, you’ve learned:
- How to configure the ComparisonOptions structure for document comparison
- How to specify source and target documents with appropriate metadata
- How to implement detailed comparison settings
- How to control the output format and location
- Best practices for different comparison scenarios
Further Practice
Try these exercises to reinforce your learning:
- Create a comparison operation that compares multiple versions of the same document
- Build a system that compares documents from different storage providers
- Implement a comparison workflow with customized settings for different document types