Skip to end of metadata
Go to start of metadata
Contents Summary

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

Extract Text from Password-Protected Documents

GroupDocs.Parser allows a user to extract text from a password protected document. It allows the opening of password protected spreadsheets, presentations, text and pdf documents.

The Recipe

To extract text from password protected documents, steps mentioned below are needed to be followed:

  • Get file path
  • Create instance of class LoadOptions
  • Set Password property of LoadOptions to the password of the document
  • Extract the file using WordsTextExtractor

The Code

Requesting a Password for Protected Documents

This feature is supported since version 18.8.

This feature allows providing a password for protected documents on-demand in case it is not known whether the document is protected or not before opening it. IPasswordProvider interface is used for this purpose.

IPasswordProvider interface has only one method:

C#

This method is called when the extractor or container meets a password-protected document. The sender contains the link to the caller. PasswordRequest class contains the following information about the request:

Member

Description

Cancel

The boolean value indicating whether the request is rejected

Password

A password for the document

A user has two ways to provide a password for the document. When the password is known, Password property of LoadOptions class is used. If it is not known whether it is protected or not before opening the document, PasswordProvider property of LoadOptions class is used as shown in the following code sample.

Labels
  • No labels