The code in below examples uses some methods defined in Common Utilities

Searching & Indexing Password Protected Documents

This feature is supported by version 16.12 or greater.

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:

  1. Using event argument to set password for protected document
  2. Using Index.Dictionaries.DocumentPasswords property to set password for protected document
  3. 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

<script src="https://gist.github.com/GroupDocsGists/a23705503d0ca014cb50ade96be2e01c.js"></script>

Following code snippet shows the event which will appear for every password protected document

<script src="https://gist.github.com/GroupDocsGists/b72f8074ee49de0d9b334eb1e5abcbb5.js"></script>

 

Using Index.Dictionaries.DocumentPasswords Property to Set Password

To set a password for protected documents using Index.Dictionaries.DocumentPasswords property, follow the following steps:

Following is the code inspect.

<script src="https://gist.github.com/GroupDocsGists/042f80a3860dca733e6a6f2f0875a6ef.js"></script>

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.

<script src="https://gist.github.com/GroupDocsGists/789ae8e4f03b9685c473283e8f066577.js"></script>

Inherit Password Dictionary from IEnumerable to Make it Work Like Other Dictionaries

This feature is supported by version 17.2 or greater

The API allows to use privileges of IEnumerable for Password dictionary. Following code snippet shows how to use GetEnumerator method.

<script src="https://gist.github.com/GroupDocsGists/8fdcf8c86c1ee361bff36fc8c7e1059e.js"></script>