Show gap lines instead of changes

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 (Comparer comparer = new Comparer(sourcePath))
{
    comparer.Add(targetPath);

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

    comparer.Compare(resultPath, options);
}

The result is as follows:

Default resultResult without LeaveGaps property
Default resultResult with LeaveGaps property

On this page