Comparer.Compare

Comparer Compare method. Compares the document with another document producing changes as number of edit and format revisions.

Compare(string, string, string, string, DateTime, CompareOptions)

Compares the document with another document producing changes as number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, string author, 
    DateTime dateTime, CompareOptions compareOptions = null)
ParameterTypeDescription
v1StringThe original document.
v2StringThe modified document.
outputFileNameStringThe output file name.
authorStringInitials of the author to use for revisions.
dateTimeDateTimeThe date and time to use for revisions.
compareOptionsCompareOptionsDocument comparison options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Demonstrates how to compare two documents.

Comparer.Compare(MyDir + "CompareV1.docx", MyDir + "CompareV2.docx", ArtifactsDir + "Compare.docx", "Wordize", DateTime.Now);

See Also


Compare(string, string, string, SaveFormat, string, DateTime, CompareOptions)

Compares the document with another document producing changes as number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, SaveFormat saveFormat, 
    string author, DateTime dateTime, CompareOptions compareOptions = null)
ParameterTypeDescription
v1StringThe original document.
v2StringThe modified document.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
authorStringInitials of the author to use for revisions.
dateTimeDateTimeThe date and time to use for revisions.
compareOptionsCompareOptionsDocument comparison options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Demonstrates how to compare two documents with char level granularity.

CompareOptions compareOptions = new CompareOptions() { Granularity = Granularity.CharLevel };
Comparer.Compare(MyDir + "CompareV1.docx", MyDir + "CompareV2.docx", ArtifactsDir + "Compare.Granularity.docx", SaveFormat.Docx, "Wordize", DateTime.Now, compareOptions);

See Also


Compare(Stream, Stream, Stream, SaveFormat, string, DateTime, CompareOptions)

Compares the document with another document producing changes as number of edit and format revisions.

public static void Compare(Stream v1, Stream v2, Stream outputStream, SaveFormat saveFormat, 
    string author, DateTime dateTime, CompareOptions compareOptions = null)
ParameterTypeDescription
v1StreamThe original document.
v2StreamThe modified document.
outputStreamStreamThe output stream.
saveFormatSaveFormatThe output’s save format.
authorStringInitials of the author to use for revisions.
dateTimeDateTimeThe date and time to use for revisions.
compareOptionsCompareOptionsDocument comparison options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.

Examples

Demonstrates how to compare two documents from streams using customized CompareOptions.

CompareOptions options = new CompareOptions();
options.IgnoreFormatting = true;
options.IgnoreHeadersAndFooters = true;

using (Stream v1 = File.OpenRead(MyDir + "CompareV1.docx"))
using (Stream v2 = File.OpenRead(MyDir + "CompareV2.docx"))
using (Stream output = File.Create(ArtifactsDir + "CompareStreams.docx"))
{
    Comparer.Compare(v1, v2, output, SaveFormat.Docx, "Wordize", DateTime.Now, options);
}

See Also