Load file from local disk

On this page

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
const groupdocs = require('@groupdocs/groupdocs.comparison');

// Define file paths for the source, target, and result DOCX files
const sourceDocxPath = 'sample-files/source.docx';
const targetDocxPath = 'sample-files/target.docx';
const resultDocxPath = 'result.docx';

// Create a Comparer instance using the source document
const comparer = new groupdocs.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.

On this page

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.