GroupDocs.Comparison allows you to compare values from the String type variables.
To compare text from variables, follow these steps:
Instantiate the LoadOptions object. Set the LoadText property to true (this indicates that the passed string contains a text to be compared, not a file path).
Instantiate the Comparer object. Specify the source variable of the String type and the LoadOptions object created in the previous step.
Call the add() method. Specify the target variable of the String type and the LoadOptions object created in the previous step.
Call the Comparer method.
Call the getResultString method to get a string with the comparison result.
The following code snippet shows how to load values from variables:
importgroupdocs.comparisonasgcdefload_text_from_string(output_file_path):# Initialize LoadOptions and set to load textload_options=gc.options.LoadOptions()load_options.load_text=True# Initialize comparer with the source text using LoadOptionswithgc.Comparer("source text",load_options)ascomparer:# Add the target text for comparison using LoadOptionscomparer.add("target text",load_options)# Compare the texts and save the resultcomparer.compare(output_file_path)# Print the result stringprint("Result string: \n"+comparer.get_result_string())# Log the success message with the output file pathprint(f"\nDocuments compared successfully.\nCheck output in {output_file_path}.")
The result is as follows:
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.