Class Comparer

Class Comparer

Namespace: Aspose.Words.LowCode
Assembly: Aspose.Words.dll (25.12.0)

Provides methods intended to compare documents.

public class Comparer : Processor

Inheritance

object Processor Comparer

Inherited Members

Processor.mResultDocument , Processor.From(string) , Processor.From(string, LoadOptions) , Processor.From(Stream) , Processor.From(Stream, LoadOptions) , Processor.To(string) , Processor.To(string, SaveOptions) , Processor.To(string, SaveFormat) , Processor.To(Stream, SaveOptions) , Processor.To(Stream, SaveFormat) , Processor.To(List<Stream>, SaveOptions) , Processor.To(List<Stream>, SaveFormat) , Processor.Execute() , Processor.Execute(CancellationToken) , Processor.ExecuteCore() , Processor.CheckArgumentsSet() , Processor.GetPartFileName(string, int, SaveFormat) , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Methods

CheckArgumentsSet()

protected override void CheckArgumentsSet()

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

Compares two documents with additional options and saves the differences to the specified output file, producing changes as a number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, string author, DateTime dateTime)

Parameters

v1 string

The original document.

v2 string

The modified document.

outputFileName string

The output file name.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

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.

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

Compares two documents with additional options and saves the differences to the specified output file, producing changes as a number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, string author, DateTime dateTime, CompareOptions compareOptions)

Parameters

v1 string

The original document.

v2 string

The modified document.

outputFileName string

The output file name.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

compareOptions CompareOptions

Document comparison options.

Examples

Shows how to simple compare documents.

// There is a several ways to compare documents:
                                                 string firstDoc = MyDir + "Table column bookmarks.docx";
                                                 string secondDoc = MyDir + "Table column bookmarks.doc";

                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.1.docx", "Author", new DateTime());
                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.2.docx", SaveFormat.Docx, "Author", new DateTime());

                                                 CompareOptions compareOptions = new CompareOptions();
                                                 compareOptions.IgnoreCaseChanges = true;
                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.3.docx", "Author", new DateTime(), compareOptions);
                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.4.docx", SaveFormat.Docx, "Author", new DateTime(), compareOptions);

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.

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

Compares two documents with additional options and saves the differences to the specified output file in the provided save format, producing changes as a number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, SaveFormat saveFormat, string author, DateTime dateTime)

Parameters

v1 string

The original document.

v2 string

The modified document.

outputFileName string

The output file name.

saveFormat SaveFormat

The output’s save format.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

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.

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

Compares two documents with additional options and saves the differences to the specified output file in the provided save format, producing changes as a number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, SaveFormat saveFormat, string author, DateTime dateTime, CompareOptions compareOptions)

Parameters

v1 string

The original document.

v2 string

The modified document.

outputFileName string

The output file name.

saveFormat SaveFormat

The output’s save format.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

compareOptions CompareOptions

Document comparison options.

Examples

Shows how to simple compare documents.

// There is a several ways to compare documents:
                                                 string firstDoc = MyDir + "Table column bookmarks.docx";
                                                 string secondDoc = MyDir + "Table column bookmarks.doc";

                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.1.docx", "Author", new DateTime());
                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.2.docx", SaveFormat.Docx, "Author", new DateTime());

                                                 CompareOptions compareOptions = new CompareOptions();
                                                 compareOptions.IgnoreCaseChanges = true;
                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.3.docx", "Author", new DateTime(), compareOptions);
                                                 Comparer.Compare(firstDoc, secondDoc, ArtifactsDir + "LowCode.CompareDocuments.4.docx", SaveFormat.Docx, "Author", new DateTime(), compareOptions);

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.

Compare(string, string, string, SaveOptions, string, DateTime)

Compares two documents with additional options and saves the differences to the specified output file in the provided save format, producing changes as a number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, SaveOptions saveOptions, string author, DateTime dateTime)

Parameters

v1 string

The original document.

v2 string

The modified document.

outputFileName string

The output file name.

saveOptions SaveOptions

The output’s save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

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.

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

Compares two documents with additional options and saves the differences to the specified output file in the provided save format, producing changes as a number of edit and format revisions.

public static void Compare(string v1, string v2, string outputFileName, SaveOptions saveOptions, string author, DateTime dateTime, CompareOptions compareOptions)

Parameters

v1 string

The original document.

v2 string

The modified document.

outputFileName string

The output file name.

saveOptions SaveOptions

The output’s save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

compareOptions CompareOptions

Document 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.

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

Compares two documents loaded from streams with additional options and saves the differences to the provided output stream in the specified save format, producing changes as a number of edit and format revisions.

public static void Compare(Stream v1, Stream v2, Stream outputStream, SaveFormat saveFormat, string author, DateTime dateTime)

Parameters

v1 Stream

The original document.

v2 Stream

The modified document.

outputStream Stream

The output stream.

saveFormat SaveFormat

The output’s save format.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

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.

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

Compares two documents loaded from streams with additional options and saves the differences to the provided output stream in the specified save format, producing changes as a number of edit and format revisions.

public static void Compare(Stream v1, Stream v2, Stream outputStream, SaveFormat saveFormat, string author, DateTime dateTime, CompareOptions compareOptions)

Parameters

v1 Stream

The original document.

v2 Stream

The modified document.

outputStream Stream

The output stream.

saveFormat SaveFormat

The output’s save format.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

compareOptions CompareOptions

Document comparison options.

Examples

Shows how to compare documents from the stream.

// There is a several ways to compare documents from the stream:
                                                          using (FileStream firstStreamIn = new FileStream(MyDir + "Table column bookmarks.docx", FileMode.Open, FileAccess.Read))
                                                          {
                                                              using (FileStream secondStreamIn = new FileStream(MyDir + "Table column bookmarks.doc", FileMode.Open, FileAccess.Read))
                                                              {
                                                                  using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.CompareStreamDocuments.1.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                      Comparer.Compare(firstStreamIn, secondStreamIn, streamOut, SaveFormat.Docx, "Author", new DateTime());

                                                                  using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.CompareStreamDocuments.2.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                  {
                                                                      CompareOptions compareOptions = new CompareOptions();
                                                                      compareOptions.IgnoreCaseChanges = true;
                                                                      Comparer.Compare(firstStreamIn, secondStreamIn, streamOut, SaveFormat.Docx, "Author", new DateTime(), compareOptions);
                                                                  }
                                                              }
                                                          }

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.

Compare(Stream, Stream, Stream, SaveOptions, string, DateTime)

Compares two documents loaded from streams with additional options and saves the differences to the provided output stream in the specified save format, producing changes as a number of edit and format revisions.

public static void Compare(Stream v1, Stream v2, Stream outputStream, SaveOptions saveOptions, string author, DateTime dateTime)

Parameters

v1 Stream

The original document.

v2 Stream

The modified document.

outputStream Stream

The output stream.

saveOptions SaveOptions

The output’s save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

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.

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

Compares two documents loaded from streams with additional options and saves the differences to the provided output stream in the specified save format, producing changes as a number of edit and format revisions.

public static void Compare(Stream v1, Stream v2, Stream outputStream, SaveOptions saveOptions, string author, DateTime dateTime, CompareOptions compareOptions)

Parameters

v1 Stream

The original document.

v2 Stream

The modified document.

outputStream Stream

The output stream.

saveOptions SaveOptions

The output’s save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

compareOptions CompareOptions

Document 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.

CompareToImages(string, string, ImageSaveOptions, string, DateTime)

Compares two documents and saves the differences as images. Each item in the returned array represents a single page of the output rendered as an image.

public static Stream[] CompareToImages(string v1, string v2, ImageSaveOptions imageSaveOptions, string author, DateTime dateTime)

Parameters

v1 string

The original document.

v2 string

The modified document.

imageSaveOptions ImageSaveOptions

The output’s image save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

Returns

Stream []

CompareToImages(string, string, ImageSaveOptions, string, DateTime, CompareOptions)

Compares two documents and saves the differences as images. Each item in the returned array represents a single page of the output rendered as an image.

public static Stream[] CompareToImages(string v1, string v2, ImageSaveOptions imageSaveOptions, string author, DateTime dateTime, CompareOptions compareOptions)

Parameters

v1 string

The original document.

v2 string

The modified document.

imageSaveOptions ImageSaveOptions

The output’s image save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

compareOptions CompareOptions

Document comparison options.

Returns

Stream []

CompareToImages(Stream, Stream, ImageSaveOptions, string, DateTime)

Compares two documents and saves the differences as images. Each item in the returned array represents a single page of the output rendered as an image.

public static Stream[] CompareToImages(Stream v1, Stream v2, ImageSaveOptions imageSaveOptions, string author, DateTime dateTime)

Parameters

v1 Stream

The original document.

v2 Stream

The modified document.

imageSaveOptions ImageSaveOptions

The output’s image save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

Returns

Stream []

CompareToImages(Stream, Stream, ImageSaveOptions, string, DateTime, CompareOptions)

Compares two documents and saves the differences as images. Each item in the returned array represents a single page of the output rendered as an image.

public static Stream[] CompareToImages(Stream v1, Stream v2, ImageSaveOptions imageSaveOptions, string author, DateTime dateTime, CompareOptions compareOptions)

Parameters

v1 Stream

The original document.

v2 Stream

The modified document.

imageSaveOptions ImageSaveOptions

The output’s image save options.

author string

Initials of the author to use for revisions.

dateTime DateTime

The date and time to use for revisions.

compareOptions CompareOptions

Document comparison options.

Returns

Stream []

Examples

Shows how to compare documents and save results as images.

// There is a several ways to compare documents:
                                                                     string firstDoc = MyDir + "Table column bookmarks.docx";
                                                                     string secondDoc = MyDir + "Table column bookmarks.doc";

                                                                     Stream[] pages = Comparer.CompareToImages(firstDoc, secondDoc, new ImageSaveOptions(SaveFormat.Png), "Author", new DateTime());

                                                                     using (FileStream firstStreamIn = new FileStream(firstDoc, FileMode.Open, FileAccess.Read))
                                                                     {
                                                                         using (FileStream secondStreamIn = new FileStream(secondDoc, FileMode.Open, FileAccess.Read))
                                                                         {
                                                                             CompareOptions compareOptions = new CompareOptions();
                                                                             compareOptions.IgnoreCaseChanges = true;
                                                                             pages = Comparer.CompareToImages(firstStreamIn, secondStreamIn, new ImageSaveOptions(SaveFormat.Png), "Author", new DateTime(), compareOptions);
                                                                         }
                                                                     }

Create()

Creates new instance of the converter processor.

public static Comparer Create()

Returns

Comparer

Create(ComparerContext)

Creates new instance of the comparer processor.

public static Comparer Create(ComparerContext context)

Parameters

context ComparerContext

Returns

Comparer

Examples

Shows how to simple compare documents using context.

// There is a several ways to compare documents:
                                                               string firstDoc = MyDir + "Table column bookmarks.docx";
                                                               string secondDoc = MyDir + "Table column bookmarks.doc";

                                                               ComparerContext comparerContext = new ComparerContext();
                                                               comparerContext.CompareOptions.IgnoreCaseChanges = true;
                                                               comparerContext.Author = "Author";
                                                               comparerContext.DateTime = new DateTime();

                                                               Comparer.Create(comparerContext)
                                                                   .From(firstDoc)
                                                                   .From(secondDoc)
                                                                   .To(ArtifactsDir + "LowCode.CompareContextDocuments.docx")
                                                                   .Execute();

Shows how to compare documents from the stream using context.

// There is a several ways to compare documents from the stream:
                                                                        using (FileStream firstStreamIn = new FileStream(MyDir + "Table column bookmarks.docx", FileMode.Open, FileAccess.Read))
                                                                        {
                                                                            using (FileStream secondStreamIn = new FileStream(MyDir + "Table column bookmarks.doc", FileMode.Open, FileAccess.Read))
                                                                            {
                                                                                ComparerContext comparerContext = new ComparerContext();
                                                                                comparerContext.CompareOptions.IgnoreCaseChanges = true;
                                                                                comparerContext.Author = "Author";
                                                                                comparerContext.DateTime = new DateTime();

                                                                                using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.CompareContextStreamDocuments.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                    Comparer.Create(comparerContext)
                                                                                        .From(firstStreamIn)
                                                                                        .From(secondStreamIn)
                                                                                        .To(streamOut, SaveFormat.Docx)
                                                                                        .Execute();
                                                                            }
                                                                        }

ExecuteCore()

protected override void ExecuteCore()
 English