Searching & Indexing Password Protected Documents
GroupDocs.Search API allows to add password protected documents to index and hence provides the functionality to search among the protected documents as well. The API sets password for indexing password protected documents in the following ways:
- Using event argument to set password for protected document
- Using Index.Dictionaries.DocumentPasswords property to set password for protected document
- Using both methods 1 and 2
Using Event Argument to Set Password
Following code snippet shows how to subscribe to PasswordRequired event to be able to specify a password
Following code snippet shows the event which will appear for every password protected document
Using Index.Dictionaries.DocumentPasswords Property to Set Password
To set a password for protected documents using Index.Dictionaries.DocumentPasswords property, follow the following steps:
- Initialize Index object by passing indexFolder.
- Set password of the protected document using index.Dictionaries.DocumentPasswords.Add(DocumentPath, Password) method
- Add documents folder to index
Following is the code inspect.
Using Both Event Argument and Index.Dictionaries.DocumentPasswords Property to Set Password
Following code snippet shows how the password for a protected document is set for indexing using both event argument and index.Dictionaories.DocumentPasswords property.
Inherit Password Dictionary from IEnumerable to Make it Work Like Other Dictionaries
The API allows to use privileges of IEnumerable for Password dictionary. Following code snippet shows how to use GetEnumerator method.