Customize changes styles

GroupDocs.Comparison provides the compare options collection to set up the appropriate comparison speed and quality.

To compare two documents with custom change style settings, follow these steps:

  1. Instantiate the Comparer object. Specify the source document path or stream.
  2. Call the Add method. Specify the target document path or stream.
  3. Instantiate the CompareOptions object. Specify the appropriate parameters.
  4. Call the Comparer method. Specify the CompareOptions object.

The following code snippets show how to compare documents with specific options:

Compare documents from local disk with custom change styles

using (Comparer comparer = new Comparer("source.docx"))
{
	comparer.Add("target.docx");
	CompareOptions compareOptions = new CompareOptions()
	{
    	 InsertedItemStyle = new StyleSettings()
         {
     	    HighlightColor = System.Drawing.Color.Red,
            FontColor = System.Drawing.Color.Green,
            IsUnderline = true,
	    IsBold = true,
	    IsStrikethrough = true,
	    IsItalic = true
         },
	 DeletedItemStyle = new StyleSettings()
         {
            HighlightColor = System.Drawing.Color.Azure,
            FontColor = System.Drawing.Color.Brown,
            IsUnderline = true,
	    IsBold = true,
	    IsStrikethrough = true,
	    IsItalic = true
         },
	 ChangedItemStyle = new StyleSettings()
         {
            HighlightColor = System.Drawing.Color.Crimson,
            FontColor = System.Drawing.Color.Firebrick,
            IsUnderline = true,
	    IsBold = true,
	    IsStrikethrough = true,
	    IsItalic = true
         }
	};
        comparer.Compare("result.docx", compareOptions);
}

The result is as follows:

Compare documents from stream with custom change styles

using (Comparer comparer = new Comparer(File.OpenRead("source.docx")))
{
	comparer.Add(File.OpenRead("target.docx"));
	CompareOptions compareOptions = new CompareOptions()
	{
    	 InsertedItemStyle = new StyleSettings()
         {
            HighlightColor = System.Drawing.Color.Red,
            FontColor = System.Drawing.Color.Green,
            IsUnderline = true,
	    IsBold = true,
	    IsStrikethrough = true,
	    IsItalic = true
         },
	 DeletedItemStyle = new StyleSettings()
         {
            HighlightColor = System.Drawing.Color.Azure,
            FontColor = System.Drawing.Color.Brown,
            IsUnderline = true,
	    IsBold = true,
	    IsStrikethrough = true,
	    IsItalic = true
         },
		ChangedItemStyle = new StyleSettings()
         {
            HighlightColor = System.Drawing.Color.Crimson,
            FontColor = System.Drawing.Color.Firebrick,
            IsUnderline = true,
	    IsBold = true,
	    IsStrikethrough = true,
	    IsItalic = true
         }
	};
        comparer.Compare(File.Create("result.docx"), compareOptions);
}