compare method

compare(v1, v2, output_file_name, author, date_time)

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

def compare(self, v1: str, v2: str, output_file_name: str, author: str, date_time: datetime.datetime):
    ...
ParameterTypeDescription
v1strThe original document.
v2strThe modified document.
output_file_namestrThe output file name.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.

compare(v1, v2, output_file_name, save_format, author, date_time)

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

def compare(self, v1: str, v2: str, output_file_name: str, save_format: aspose.words.SaveFormat, author: str, date_time: datetime.datetime):
    ...
ParameterTypeDescription
v1strThe original document.
v2strThe modified document.
output_file_namestrThe output file name.
save_formatSaveFormatThe output’s save format.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.

compare(v1, v2, output_file_name, author, date_time, compare_options)

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.

def compare(self, v1: str, v2: str, output_file_name: str, author: str, date_time: datetime.datetime, compare_options: aspose.words.comparing.CompareOptions):
    ...
ParameterTypeDescription
v1strThe original document.
v2strThe modified document.
output_file_namestrThe output file name.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.
compare_optionsCompareOptionsDocument comparison options.

compare(v1, v2, output_file_name, save_format, author, date_time, compare_options)

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.

def compare(self, v1: str, v2: str, output_file_name: str, save_format: aspose.words.SaveFormat, author: str, date_time: datetime.datetime, compare_options: aspose.words.comparing.CompareOptions):
    ...
ParameterTypeDescription
v1strThe original document.
v2strThe modified document.
output_file_namestrThe output file name.
save_formatSaveFormatThe output’s save format.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.
compare_optionsCompareOptionsDocument comparison options.

compare(v1, v2, output_file_name, save_options, author, date_time, compare_options)

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.

def compare(self, v1: str, v2: str, output_file_name: str, save_options: aspose.words.saving.SaveOptions, author: str, date_time: datetime.datetime, compare_options: aspose.words.comparing.CompareOptions):
    ...
ParameterTypeDescription
v1strThe original document.
v2strThe modified document.
output_file_namestrThe output file name.
save_optionsSaveOptionsThe output’s save options.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.
compare_optionsCompareOptionsDocument comparison options.

compare(v1, v2, output_stream, save_format, author, date_time)

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

def compare(self, v1: io.BytesIO, v2: io.BytesIO, output_stream: io.BytesIO, save_format: aspose.words.SaveFormat, author: str, date_time: datetime.datetime):
    ...
ParameterTypeDescription
v1io.BytesIOThe original document.
v2io.BytesIOThe modified document.
output_streamio.BytesIOThe output stream.
save_formatSaveFormatThe output’s save format.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.

compare(v1, v2, output_stream, save_format, author, date_time, compare_options)

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.

def compare(self, v1: io.BytesIO, v2: io.BytesIO, output_stream: io.BytesIO, save_format: aspose.words.SaveFormat, author: str, date_time: datetime.datetime, compare_options: aspose.words.comparing.CompareOptions):
    ...
ParameterTypeDescription
v1io.BytesIOThe original document.
v2io.BytesIOThe modified document.
output_streamio.BytesIOThe output stream.
save_formatSaveFormatThe output’s save format.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.
compare_optionsCompareOptionsDocument comparison options.

compare(v1, v2, output_stream, save_options, author, date_time, compare_options)

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.

def compare(self, v1: io.BytesIO, v2: io.BytesIO, output_stream: io.BytesIO, save_options: aspose.words.saving.SaveOptions, author: str, date_time: datetime.datetime, compare_options: aspose.words.comparing.CompareOptions):
    ...
ParameterTypeDescription
v1io.BytesIOThe original document.
v2io.BytesIOThe modified document.
output_streamio.BytesIOThe output stream.
save_optionsSaveOptionsThe output’s save options.
authorstrInitials of the author to use for revisions.
date_timedatetime.datetimeThe date and time to use for revisions.
compare_optionsCompareOptionsDocument comparison options.

Examples

Shows how to simple compare documents.

# There is a several ways to compare documents:
first_doc = MY_DIR + 'Table column bookmarks.docx'
second_doc = MY_DIR + 'Table column bookmarks.doc'
aw.lowcode.Comparer.compare(v1=first_doc, v2=second_doc, output_file_name=ARTIFACTS_DIR + 'LowCode.CompareDocuments.1.docx', author='Author', date_time=datetime.datetime(1, 1, 1))
aw.lowcode.Comparer.compare(v1=first_doc, v2=second_doc, output_file_name=ARTIFACTS_DIR + 'LowCode.CompareDocuments.2.docx', save_format=aw.SaveFormat.DOCX, author='Author', date_time=datetime.datetime(1, 1, 1))
compare_options = aw.comparing.CompareOptions()
compare_options.ignore_case_changes = True
aw.lowcode.Comparer.compare(v1=first_doc, v2=second_doc, output_file_name=ARTIFACTS_DIR + 'LowCode.CompareDocuments.3.docx', author='Author', date_time=datetime.datetime(1, 1, 1), compare_options=compare_options)
aw.lowcode.Comparer.compare(v1=first_doc, v2=second_doc, output_file_name=ARTIFACTS_DIR + 'LowCode.CompareDocuments.4.docx', save_format=aw.SaveFormat.DOCX, author='Author', date_time=datetime.datetime(1, 1, 1), compare_options=compare_options)

Shows how to compare documents from the stream.

# There is a several ways to compare documents from the stream:
with system_helper.io.FileStream(MY_DIR + 'Table column bookmarks.docx', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as first_stream_in:
    with system_helper.io.FileStream(MY_DIR + 'Table column bookmarks.doc', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as second_stream_in:
        with system_helper.io.FileStream(ARTIFACTS_DIR + 'LowCode.CompareStreamDocuments.1.docx', system_helper.io.FileMode.CREATE, system_helper.io.FileAccess.READ_WRITE) as stream_out:
            aw.lowcode.Comparer.compare(v1=first_stream_in, v2=second_stream_in, output_stream=stream_out, save_format=aw.SaveFormat.DOCX, author='Author', date_time=datetime.datetime(1, 1, 1))
        with system_helper.io.FileStream(ARTIFACTS_DIR + 'LowCode.CompareStreamDocuments.2.docx', system_helper.io.FileMode.CREATE, system_helper.io.FileAccess.READ_WRITE) as stream_out:
            compare_options = aw.comparing.CompareOptions()
            compare_options.ignore_case_changes = True
            aw.lowcode.Comparer.compare(v1=first_stream_in, v2=second_stream_in, output_stream=stream_out, save_format=aw.SaveFormat.DOCX, author='Author', date_time=datetime.datetime(1, 1, 1), compare_options=compare_options)

See Also