This article describes how to compare Word documents with Nodej.s REST API. You will learn to compare Word files with Nodej.s Low Code API using the Nodej.s cloud SDK. Complete program flow and a sample code are available to perform this task online.
Prerequisite
- Create an account and get API credentials
- Download Aspose.Words Cloud SDK for Nodej.s to compare two Word files
- Setup Nodej.s solution project with the above SDK for comparing the DOCX files
Steps Compare Two Word Docs with Nodej.s Low Code API
- Initialize the WordsApi object by setting the cloned ID and secret to compare the documents
- Read the latest Word file into the memory stream and upload it to the cloud storage
- Create the CompareData object and use the uploaded file as a reference
- Read the initial Word file into the memory stream
- Create the CompareDocumentOnlineRequest object by providing the initial Word file, updated Word file and the output file name
- Invoke the CompareDocumentOnline method and provide the request object
- Download the output Word file from the response and save it on the disk
The above steps describe how to compare Word docs online with Nodej.s Low Code API. Commence the process by uploading the latest Word file to cloud storage followed by creating the CompareData object using the uploaded document reference. Read the original file into the memory stream, create the CompareDocumentOnlineRequest with the uploaded Word file, local document with changes, and the output Word file and finally call the CompareDocumentOnline() method to compare the Word files.
Code to Compare Word Documents Online with Nodej.s REST API
This code demonstrates the process to compare differences between two Word documents with Nodej.s REST API. This code shows that first we upload the latest Word file into the cloud storage as a reference and read the previous version of the Word file locally to compare it with the reference Word file. In the CompareData class, there is a property named CompareOptions that supports the customization of the comparison such as ignoring case changes, comments, fields, footnotes, formatting, headers and footers, tables and text boxes.
In this topic, we have learned to compare two Word files. For deleting the comments in a Word file, refer to the following article: Delete Comments in Word DOC with Nodej.s REST API.