Created
February 4, 2025 10:05
-
-
Save groupdocs-cloud-kb/1ba5f3e45f86ffb2f25ea92e41f196aa to your computer and use it in GitHub Desktop.
Compare Word Documents using Node.js REST API
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
// Step 1: Import the GroupDocs.Comparison.Cloud module | |
const comparison_cloud = require("groupdocs-comparison-cloud"); | |
// Step 2: Define your API credentials | |
const MyAppKey = "your-app-key"; | |
const MyAppSid = "your-app-sid"; | |
// Step 3: Initialize the CompareApi with API credentials | |
const compareApi = comparison_cloud.CompareApi.fromKeys(MyAppKey, MyAppSid); | |
// Step 4: Compare two Word (DOCX) documents | |
(async () => { | |
try { | |
// Define source and target files in cloud storage | |
const sourceFile = new comparison_cloud.FileInfo(); | |
sourceFile.filePath = "SampleFiles/source.docx"; | |
const targetFile = new comparison_cloud.FileInfo(); | |
targetFile.filePath = "SampleFiles/target.docx"; | |
// Set up comparison options | |
const options = new comparison_cloud.ComparisonOptions(); | |
options.sourceFile = sourceFile; | |
options.targetFiles = [targetFile]; | |
options.outputPath = "comparison/result.docx"; // Output file path | |
// Create a comparison request | |
const request = new comparison_cloud.ComparisonsRequest(options); | |
// Perform the document comparison | |
const response = await compareApi.comparisons(request); | |
} catch (error) { | |
console.error("Error during file comparison:", error.message); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment