Compare multiple documents protected by password
Leave feedback
On this page
Note
This feature is available only for Word documents, PowerPoint, and Open Document presentations.
GroupDocs.Comparison allows you to compare more than two password-protected documents.
To compare several password-protected documents, follow these steps:
Instantiate the LoadOptions object. Specify the password for the source document.
Instantiate the Comparer object. Specify the source document path or stream and the LoadOptions object created in the previous step.
Instantiate another LoadOptions object and specify the password for the target document.
Call the add() method and specify the target document path or stream and the LoadOptions object created in step 3. Repeat steps 3 and 4 for every target document.
Call the compare() method.
The following code snippets show how to compare several password-protected documents:
Compare several password-protected documents from a local disk
importgroupdocs.comparisonasgcdefcompare_multiple_documents_protected_path(source_path,target_paths,source_password,target_passwords,output_file_name):# Initialize the comparer with the source file path and load optionsload_options_source=gc.options.LoadOptions()load_options_source.password=source_passwordcomparer=gc.Comparer(source_path,load_options_source)# Add target files and load optionsfortarget_path,target_passwordinzip(target_paths,target_passwords):load_options_target=gc.options.LoadOptions()load_options_target.password=target_passwordcomparer.add(target_path,load_options_target)# Perform the compare operation and save the resultcomparer.compare(output_file_name)print(f"\nDocuments compared successfully.\nCheck output in {output_file_name}.")
Compare several password-protected documents from a stream
importgroupdocs.comparisonasgcdefcompare_multiple_documents_protected_path(source_path,target_paths,source_password,target_passwords,output_file_name):# Initialize the comparer with the source stream and load optionswithopen(source_path,'rb')assource_stream:load_options_source=gc.options.LoadOptions()load_options_source.password=source_passwordcomparer=gc.Comparer(source_stream,load_options_source)# Add target streams and load optionstarget_streams=[]fortarget_path,target_passwordinzip(target_paths,target_passwords):target_stream=open(target_path,'rb')target_streams.append(target_stream)load_options_target=gc.options.LoadOptions()load_options_target.password=target_passwordcomparer.add(target_stream,load_options_target)# Perform the compare operation and save the resultcomparer.compare(output_file_name)# Close target streams after comparisonfortarget_streamintarget_streams:target_stream.close()print(f"\nDocuments compared successfully.\nCheck output in {output_file_name}.")
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.