Load Options

Use groupdocs.parser.options.LoadOptions to pass extra parameters when opening a document, such as a password or file type when loading from a stream.

Open a password-protected document

from groupdocs.parser import Parser
from groupdocs.parser.options import LoadOptions

options = LoadOptions("123456")

with Parser("protected.pdf", options) as parser:
    reader = parser.get_text()
    text = reader.read_to_end() if reader is not None else None
    print(text if text is not None else "Text extraction isn't supported.")

The following sample file is used in this example: protected.pdf

Payroll summary - December 2025
Confidential: prepared by Finance for the directors of Harbor Lane Provisions.
Department                              Headcount          Gross pay            Employer costs
Warehouse                               21                 $71,400              $13,900
Drivers                                 9                  $29,700              $5,800
Sales and customer service              7                  $27,300              $5,300
Procurement               
[TRUNCATED]

Download full output

Load from a stream

When you read from a stream, provide LoadOptions so the parser knows how to open the content (for example, password-protected PDF streams).

from groupdocs.parser import Parser
from groupdocs.parser.options import LoadOptions

with open("protected.pdf", "rb") as stream:
    options = LoadOptions("123456")
    with Parser(stream, options) as parser:
        reader = parser.get_text()
        text = reader.read_to_end() if reader is not None else None
        print(text if text is not None else "Text extraction isn't supported.")

The following sample file is used in this example: protected.pdf

Payroll summary - December 2025
Confidential: prepared by Finance for the directors of Harbor Lane Provisions.
Department                              Headcount          Gross pay            Employer costs
Warehouse                               21                 $71,400              $13,900
Drivers                                 9                  $29,700              $5,800
Sales and customer service              7                  $27,300              $5,300
Procurement               
[TRUNCATED]

Download full output

Tips

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.