Free Support Forum -

How to compare two word documents content using aspose.words?

how to compare two word documents content using aspose.words.....previously u gave solution tht to extract text from word document into text file and then compare tht two text files?

1.can you pls provide me sample code how to compare two text files content?

2.Is there any other way of doing how to compare two word documents content using aspose.words without converting to text files?..see below forum previously i posted

<A href="</A></P> <P> </P>


Thanks for your request. As I mentioned earlier, Aspose.Words does not provide a document comparison feature. We will consider adding such feature in one of future versions of Aspose.Words, but unfortunately I cannot promise you that this feature will be available any time soon.

MS Word documents are very complex and it is very difficult to compare them. If you need just compare content of documents, you can convert both documents to txt and compare two strings. Please see the following code and comments:

Document doc1 = new Document("C:\\Temp\\doc1.doc");

Document doc2 = new Document("C:\\Temp\\doc2.doc");

// GetText will retrieve all field codes and special characters

Console.WriteLine("GetText() Result Document1: " + doc1.GetText());

Console.WriteLine("GetText() Result Document2: " + doc2.GetText());

// You can compare two documents here

if (doc1.GetText() == doc2.GetText())

Console.WriteLine("Document content (including all field codes and special characters) are identical");

// ToTxt will not retrieve fields code or special characters, but will still contain some natural formatting characters

// such as paragraph markers etc. This is the same as "viewing" the document as if it was opened in a text editor

// Only the results of fields are shown without any internal codes or characters

Console.WriteLine("ToTxt() Result Document1: " + doc1.ToTxt());

Console.WriteLine("ToTxt() Result Document2: " + doc2.ToTxt());

if (doc1.ToTxt() == doc2.ToTxt())

Console.WriteLine("Document content (without fields code or special characters) are identical");

Best regards,

Thnaks for ur rly…but i need to compare two word documents content using aspose.words in javascript(client side)…pls help me out…


Thanks for your request. I'm afraid there is no way to achieve what you need using Aspose.Words. Please see the following link to learn more about supported platforms:

Best regards,