This project is read-only.

Compare Two Documents in C# and Generate a Diff View in ASP.NET

Please note: This C# sample is created based on the GroupDocs.Comparison for .NET library and is aimed to demonstrate its key features. In order to setup and run the project, you will need to download the GroupDocs.Comparison for .NET library (a free evaluation available) from this page. If you’d like to test the library without any restrictions, please feel free to contact GroupDocs support for a free 30-day license.

First, let’s take a closer look at the library itself. GroupDocs.Comparison for .NET is a multi-format document comparison library capable of comparing two PDF files, up to 3 Microsoft Word documents, as well as two Excel, PowerPoint, HTML, ODT and TXT files. The library can be used to compare documents programmatically on the server side and also to display compared documents with highlighted differences in ASP.NET. Depending on the document type, the library detects content-related differences, document structure and style changes (e.g. italic, bold, regular text styles, etc.).

Key Features of the Library

1. Easy deployment. GroupDocs.Comparison for .NET is designed as a middleware for easy integration into any document management workflow. It is written in a 100% managed code, can be used in any .NET project and doesn’t have any 3rd party dependencies.

2. Out-of-the box diff view UI. Specifically for ASP.NET projects (both WebForms and MVC 3+), the library provides comprehensive API methods and a diff view UI that allows you to display compared documents with highlighted differences on a web-page.

This works the following way: the library merges two documents on the server, detects differences between them, then converts the merged documents into web-compatible content and transfers it to the client. In the output, end users see a resulting (merged) document with highlighted differences:

Compare Two Documents in C# - Diff View Library

Since documents are converted to web compatible content, end users can view them from any modern browser without the need to install any office software or browser plugins. In addition, the library comes with an embeddable GUI that provides end users with convenient tools for browsing through the documents they compare. For example, users can see a list of all found differences, jump between spotted differences through the document, search for text, etc.    

3. Advanced handling of Word documents. The library allows you to compare up to 3 Word documents, accept/reject each found difference and then save the compared documents in a final file. Alternatively, you can leave the found differences untouched and save the merged documents in a Word file with the "Track Changes" feature enabled, so that the document can be reviewed/edited offline later on.

System Requirements

GroupDocs.Comparison for .NET is a .NET assembly, so it requires an installed .NET Framework version 4.0+.

In order to use the library in conjunction with the diff view UI, you should also have an ASP.NET WebForms, or ASP.NET MVC version 3+ installed. When using in ASP.NET, GroupDocs.Comparison for .NET requires System.Web.Optimization.dll version and WebGrease.dll version 1.6.5135.21930. Both of these libraries are included into this sample.

Of course, you need to have a web-server in order to run the sample. You can open it using Microsoft Visual Studio 2012 or above and run via IIS Express. Alternatively, you can create a web-site using the IIS Manager and run it under IIS. Please take into account that the ASP.NET Development Server, also known as Cassini, is not supported by GroupDocs.Comparison for .NET.

As already mentioned at the very beginning, this sample is built based on the commercial library - GroupDocs.Comparison for .NET. In order to setup and run the project, you will need to download the library (a free evaluation available) from this page. If you’d like to test the library without any restrictions, please feel free to contact GroupDocs support from this page for a free 30-day license.

For a detailed guide on how to configure the sample, compare two documents programmatically and display found diffs in ASP.NET, please see documentation for this project.

Last edited Sep 16, 2015 at 1:11 PM by GroupDocs, version 18