This repository contains GroupDocs.Comparison Cloud SDK for Apex source code. This SDK allows you to work with GroupDocs.Comparison Cloud REST APIs in your Salesforce projects.
The complete source code is available in this repository folder, you can either directly use it in your project. For more details, please visit our documentation website.
- Register at Dashboard and obtain your API Keys on the Applications tab;
- Check out this repository and perform login into your Salesforce organization, using SFDX (sfdx auth:web:login -r https://login.salesforce.com);
- Push classes into org using command: "sf project deploy start";
- Upload necessary content files using Salesforce dashboard at "Files" page;
- Add GroupDocs Cloud API enpoint at "Remote Site Settings" page, when adding new site, set "Remote Site URL" field to "https://api.groupdocs.cloud";
- Write a code that uses GroupDocs.Comparison Cloud SDK, see example below, and execute in the developer console or use in your custom classes;
// Create config and API instances
Configuration config = new Configuration('YOUR_API_KEY', 'YOUR_API_SECRET');
FileApi fileApi = new FileApi(config);
CompareApi compareApi = new CompareApi(config);
// Upload files for comparison to cloud storage
List<ContentVersion> contentVersions = [SELECT Id, Title, VersionData FROM ContentVersion WHERE Title = 'source.docx' LIMIT 1];
fileApi.uploadFile(new UploadFileRequest('source.docx', contentVersions[0].VersionData, null));
List<ContentVersion> contentVersions = [SELECT Id, Title, VersionData FROM ContentVersion WHERE Title = 'target.docx' LIMIT 1];
fileApi.uploadFile(new UploadFileRequest('target.docx', contentVersions[0].VersionData, null));
// Get comparison changes
ComparisonOptions options = new ComparisonOptions();
options.SourceFile = new FileInfo();
options.SourceFile.FilePath='source.docx';
options.TargetFiles = new List<FileInfo>();
options.TargetFiles.add(new FileInfo());
options.TargetFiles[0].FilePath = 'target.docx';
options.Settings = new Settings();
options.Settings.GenerateSummaryPage = true;
options.Settings.ShowDeletedContent = true;
options.Settings.StyleChangeDetection = true;
List<ChangeInfo> response = compareApi.postChanges(new PostChangesRequest(options));
System.debug('The num of changes: ' + response.size());
All GroupDocs.Comparison Cloud SDKs are licensed under MIT License.
Your feedback is very important to us. Please feel free to contact us using our Support Forums.