Our powerful JavaScript SDK allows you to find the difference between HTML documents and save the results to a convenient format for viewing. To verify our product capabilities, compare HTML files using this JavaScript library and see the differences.
Our Node SDK is designed to give you the most accurate result, even though comparison is a complex function itself.
Sometimes you need to be sure that the document in the HTML format has not been changed, and if it has, you need to find out what the difference is. Just use our Node diff tool to compare two HTML files and find differences in whole words or single characters. Moreover, if only one character in a word has changed, this word will be marked as changed entirely.
Now you no longer need to spend time manually comparing HTML documents, and you can quickly find even small changes and export such diffs to a document in a convenient format.
Check out how our solution to compare HTML files using Node SDK works. To achieve this, load the HTML files you want to compare and select the export file format – it will be automatically loaded after comparing.
Note that you need to accept all revisions in compared documents before calling the comparison method, as shown in our example:
import * as fs from "fs";
const wordsApi = new WordsApi("####-####-####-####-####", "##################");
const fileName1 = "Input1.html";
const fileName2 = "Input2.html";
const fileResult = "Output.html";
// Upload documents to cloud storage.
const firstDocumentContent = fs.createReadStream(fileName1);
const uploadFirstFileRequest = new model.UploadFileRequest({
fileContent: firstDocumentContent,
path: fileName1
});
wordsApi.uploadFile(uploadFirstFileRequest)
.then((uploadFirstFileRequestResult) => {
// tslint:disable-next-line:no-console
console.log("Result of UploadFirstFileRequest: ", uploadFirstFileRequestResult);
const secondDocumentContent = fs.createReadStream(fileName2);
const uploadSecondFileRequest = new model.UploadFileRequest({
fileContent: secondDocumentContent,
path: fileName2
});
wordsApi.uploadFile(uploadSecondFileRequest)
.then((uploadSecondFileRequestResult) => {
// tslint:disable-next-line:no-console
console.log("Result of UploadSecondFileRequest: ", uploadSecondFileRequestResult);
// Compare documents in cloud.
const compareDataOptions = new model.CompareData({
author: "author",
fileReference: model.FileReference.fromRemoteFilePath(fileName2)
})
const compareDocumentRequest = new model.CompareDocumentRequest({
name: fileName1,
compareData: compareDataOptions,
destFileName: fileResult
});
wordsApi.compareDocument(compareDocumentRequest)
.then((compareDocumentRequestResult) => {
// tslint:disable-next-line:no-console
console.log("Result of CompareDocumentRequest: ", compareDocumentRequestResult);
// Download result document from cloud storage.
const downloadFileRequest = new model.DownloadFileRequest({
path: fileResult
});
wordsApi.downloadFile(downloadFileRequest)
.then((downloadFileRequestResult) => {
// tslint:disable-next-line:no-console
console.log("Result of DownloadFileRequest: ", downloadFileRequestResult);
fs.writeFileSync(fileResult, downloadFileRequestResult.body);
});
});
});
});
Install 'Aspose.Words Cloud SDK for Node.js' using NPM package manager. Run npm install asposewordscloud --save from the command line to install the SDK via the NPM package manager. As an alternative, you can manually clone Aspose.Words Cloud SDK for Node.js source code from GitHub and use it in your project. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.
Refer to the Repository Documentation to see more details.
You can perform compare operation for other file formats: