Show gap lines instead of changes

On this page

GroupDocs.Comparison allows you to adjust the 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 replaces the changed content with empty lines. To use this property, activate the ShowInsertedContent and ShowDeletedContent properties.

Follow these steps to adjust the 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. Set the ShowInsertedContent, ShowDeletedContent, and/or LeaveGaps properties.
  4. Call the compare() method. Specify the CompareOptions object from the previous step.

The following code snippet shows how to get the desired result

const comparer = new groupdocs.comparison.Comparer(sourcePath);
comparer.add(targetPath);

const options = new groupdocs.comparison.CompareOptions();
options.setShowInsertedContent(false);
options.setShowDeletedContent(false);
options.setLeaveGaps(true);

comparer.compare(resultPath, options);

The result is as follows:

Default resultResult without LeaveGaps property
Default resultResult with LeaveGaps property

On this page