Set shape color independently of font color

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison provides the option to specify the color for changed shapes.

To compare two documents with custom change color for shapes, 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 ShapeColor for the InsertedItemStyle/DeletedItemStyle/ChangedItemStyle parameters.
  4. Set MarkChangedContent to true.
  5. Call the compare() method. Specify the CompareOptions object.

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

Compare documents from local disk with custom change color for shapes

import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.options.CompareOptions;
import com.groupdocs.comparison.options.style.StyleSettings;
import java.awt.Color;
// ...

try (Comparer comparer = new Comparer("source.docx")) {
    comparer.add("target.docx");

    CompareOptions compareOptions = new CompareOptions();
    compareOptions.setDetectStyleChanges(true);
    compareOptions.setMarkChangedContent(true);

    final StyleSettings insertedStyleSettings = new StyleSettings();
    insertedStyleSettings.setFontColor(Color.BLUE);
    insertedStyleSettings.setShapeColor(new Color(128, 0, 128)); // purple
    compareOptions.setInsertedItemStyle(insertedStyleSettings);

    final StyleSettings deletedStyleSettings = new StyleSettings();
    deletedStyleSettings.setFontColor(Color.RED);
    deletedStyleSettings.setShapeColor(Color.ORANGE);
    compareOptions.setDeletedItemStyle(deletedStyleSettings);

    final StyleSettings changedStyleSettings = new StyleSettings();
    changedStyleSettings.setFontColor(Color.GREEN);
    changedStyleSettings.setShapeColor(new Color(144, 238, 144)); // light green
    compareOptions.setChangedItemStyle(changedStyleSettings);

    comparer.compare("result.docx", compareOptions);
}

The result is as follows:

See also