When the source file is located on the local disk, GroupDocs.Comparison allows you to load it using the Comparer class constructor by specifying an absolute or relative path. To load the target file located on the local disk, use the add() method. Specify an absolute or relative path as the parameter.
The following code snippet shows how to load files from a local disk:
'use strict';// Import the GroupDocs Comparison Node.js SDK
constgroupdocs=require('@groupdocs/groupdocs.comparison');// Define file paths for the source, target, and result DOCX files
constsourceDocxPath='sample-files/source.docx';consttargetDocxPath='sample-files/target.docx';constresultDocxPath='result.docx';// Create a Comparer instance using the source document
constcomparer=newgroupdocs.Comparer(sourceDocxPath);// Add the target document to the comparison set
comparer.add(targetDocxPath);// Perform the comparison and write the merged result to the output file
comparer.compare(resultDocxPath);// Terminate the process with a success exit code
process.exit(0);
This example demonstrates the simplest way to compare documents from local disk storage. It creates a Comparer instance by passing the source document path directly to the constructor, adds the target document using the add() method with its file path, and then performs the comparison by calling compare() with the result file path. The result document will contain all detected differences between the source and target documents.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.