Show gap lines instead of changes

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 →

On this page


GroupDocs.Comparison allows you to adjust appearance of the output document.

By default, changes from the two input files (source and target files) are added to the output document and highlighted. Use the ShowInsertedContent and ShowDeletedContent properties to configure the content of the output file.

Use the LeaveGaps property to adjust the display of the output document, which allows to replace changed content with empty lines. To use this property, activate the ShowInsertedContent and ShowDeletedContent properties.

Follow these steps to adjust appearance of the output document:

  1. Instantiate the Comparer object. Specify the source file path or stream.
  2. Call the Add method. Specify the target file path or stream.
  3. Instantiate the CompareOptions object. Sets the ShowInsertedContent, ShowDeletedContent, and/or LeaveGaps properties.
  4. Call the Comparer method. Specify the CompareOptions object from the previous step.

The following code snippet shows how get the desired result

using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...

using (Comparer comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");

    CompareOptions options = new CompareOptions();
    options.ShowInsertedContent = false;
    options.ShowDeletedContent = false;
    options.LeaveGaps = true;

    comparer.Compare("result.docx", options);
}

The result is as follows:

Default resultResult without LeaveGaps property
Default resultResult with LeaveGaps property

On this page