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
compare()
method. Specify theCompareOptions
object.
The following code snippets show how to compare documents with specific options:
const comparer = new groupdocs.comparison.Comparer(sourceFile);
comparer.add(targetFile);
const compareOptions = new groupdocs.comparison.CompareOptions();
const insertedStyleSettings = new groupdocs.comparison.StyleSettings();
insertedStyleSettings.setHighlightColor(Color.RED);
insertedStyleSettings.setFontColor(Color.GREEN);
insertedStyleSettings.setUnderline(true);
insertedStyleSettings.setBold(true);
insertedStyleSettings.setStrikethrough(true);
insertedStyleSettings.setItalic(true);
compareOptions.setInsertedItemStyle(insertedStyleSettings);
const deletedStyleSettings = new groupdocs.comparison.StyleSettings();
deletedStyleSettings.setHighlightColor(Color.PINK);
deletedStyleSettings.setFontColor(Color.CYAN);
deletedStyleSettings.setUnderline(true);
deletedStyleSettings.setBold(true);
deletedStyleSettings.setStrikethrough(true);
deletedStyleSettings.setItalic(true);
compareOptions.setDeletedItemStyle(deletedStyleSettings);
const changedStyleSettings = new groupdocs.comparison.StyleSettings();
changedStyleSettings.setHighlightColor(Color.LIGHT_GRAY);
changedStyleSettings.setFontColor(Color.GRAY);
changedStyleSettings.setUnderline(true);
changedStyleSettings.setBold(true);
changedStyleSettings.setStrikethrough(true);
changedStyleSettings.setItalic(true);
compareOptions.setChangedItemStyle(changedStyleSettings);
const resultPath = comparer.compare(resultFile, compareOptions);
The result is as follows:
const comparer = new groupdocs.comparison.Comparer(sourceInputStream);
comparer.add(targetInputStream);
const compareOptions = new groupdocs.comparison.CompareOptions();
const insertedStyleSettings = new groupdocs.comparison.StyleSettings();
insertedStyleSettings.setHighlightColor(Color.RED);
insertedStyleSettings.setFontColor(Color.GREEN);
insertedStyleSettings.setUnderline(true);
insertedStyleSettings.setBold(true);
insertedStyleSettings.setStrikethrough(true);
insertedStyleSettings.setItalic(true);
compareOptions.setInsertedItemStyle(insertedStyleSettings);
const deletedStyleSettings = new groupdocs.comparison.StyleSettings();
deletedStyleSettings.setHighlightColor(Color.PINK);
deletedStyleSettings.setFontColor(Color.CYAN);
deletedStyleSettings.setUnderline(true);
deletedStyleSettings.setBold(true);
deletedStyleSettings.setStrikethrough(true);
deletedStyleSettings.setItalic(true);
compareOptions.setDeletedItemStyle(deletedStyleSettings);
const changedStyleSettings = new groupdocs.comparison.StyleSettings();
changedStyleSettings.setHighlightColor(Color.LIGHT_GRAY);
changedStyleSettings.setFontColor(Color.GRAY);
changedStyleSettings.setUnderline(true);
changedStyleSettings.setBold(true);
changedStyleSettings.setStrikethrough(true);
changedStyleSettings.setItalic(true);
compareOptions.setChangedItemStyle(changedStyleSettings);
const resultPath = comparer.compare(resultInputStream, 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.