To avoid the saving stream as a file, GroupDocs.Comparison allows you to work with file streams directly.
To work with a stream, follow these steps:
Obtain a file stream.
Pass the opened source file stream to the Comparer class constructor or pass the opened target file stream to the add() method.
The following code snippet shows how to load a file from a stream:
importgroupdocs.comparisonasgcdefload_file_from_stream(output_file_path,source_file_path,target_file_path):withopen(source_file_path,'rb')assource_stream:withgc.Comparer(source_stream)ascomparer:# Add the target document for comparison using a file streamwithopen(target_file_path,'rb')astarget_stream:comparer.add(target_stream)# Compare the documents and save the resultcomparer.compare(output_file_path)# Log the success message with the output file pathprint(f"\nDocuments compared successfully.\nCheck output in {output_file_path}.")
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.