This example demonstrates how to load a password-protected document. Provide the password through LoadOptions. If the password is wrong, a DocumentProtectedException is raised.
fromgroupdocs.metadataimportMetadatafromgroupdocs.metadata.optionsimportLoadOptionsdefload_password_protected_document():# Specify the passwordload_options=LoadOptions()load_options.password="123"withMetadata("protected.docx",load_options)asmetadata:# Extract, edit or remove metadata hereprint(f"Opened protected {metadata.file_format} document")if__name__=="__main__":load_password_protected_document()
protected.docx is the sample file used in this example (password: 123). Click here to download it.