Customize changes styles
Leave feedback
On this page
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:
- Instantiate the Comparer object. Specify the source document path or stream.
- Call the Add method. Specify the target document path or stream.
- Instantiate the CompareOptions object. Specify the appropriate parameters.
- Call the Comparer method. Specify the CompareOptions object.
The following code snippets show how to compare documents with specific options:
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...
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:
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
using System.IO;
// ...
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);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.