This guide provides a quick overview of how to set up and start using GroupDocs.Parser for Python via .NET. The library opens a document and extracts its text, tables, images, metadata and more, whatever the format.
For best practices, use a virtual environment to manage dependencies in Python applications. Learn more about virtual environments at the Create and Use Virtual Environments documentation topic.
Create and Activate a Virtual Environment
Create a virtual environment:
py-mvenv.venv
python3 -m venv .venv
python3 -m venv .venv
Activate a virtual environment:
.venv\Scripts\activate
source .venv/bin/activate
source .venv/bin/activate
Install groupdocs-parser-net Package
After activating the virtual environment, run the following command in your terminal to install the latest version of the package:
py-mpipinstallgroupdocs-parser-net
python3 -m pip install groupdocs-parser-net
python3 -m pip install groupdocs-parser-net
Ensure the package is installed successfully. You should see the message
To quickly test the library, let’s extract the text of a PDF report.
importosfromgroupdocs.parserimportParser,Licensedefextract_text():# Optionally set a licenselicense_path=os.path.abspath("./GroupDocs.Parser.lic")ifos.path.exists(license_path):License().set_license(license_path)# Open the document and extract its textwithParser("./sample.pdf")asparser:text=parser.get_text()iftextisNone:print("Text extraction isn't supported for this format")else:print(text)if__name__=="__main__":extract_text()
sample.pdf is the sample file used in this example. Click here to download it.
Investor relations
Annual Report 2025 | Port Ellery
Annual Report 2025
1. Overview
Harbor Lane Provisions supplies specialty food to 1,265 independent grocers, cafes and restaurants from its
Quayside warehouse in Port Ellery. In 2025 net revenue grew 15.1% to $21.4 million, driven by the Autumn
[TRUNCATED]
After running the app you can deactivate the virtual environment by executing deactivate or closing your shell.
Explanation
Parser("./sample.pdf"): Opens the document. Used as a context manager so the native document handle is released.
parser.get_text(): Extracts the text of the whole document as a str, or returns None for a format that has no text extraction. Pass a page index, as in get_text(0), to extract one page.
Example 2: Read metadata
In this example we read the document properties of the same report: its title, subject, author and dates.
importosfromgroupdocs.parserimportParser,Licensedefextract_metadata():# Optionally set a licenselicense_path=os.path.abspath("./GroupDocs.Parser.lic")ifos.path.exists(license_path):License().set_license(license_path)# Open the document and print each metadata itemwithParser("./sample.pdf")asparser:metadata=parser.get_metadata()ifmetadataisNone:print("Metadata extraction isn't supported for this format")else:foriteminmetadata:print(item.name,"=",item.value)if__name__=="__main__":extract_metadata()
sample.pdf is the sample file used in this example. Click here to download it.
parser.get_metadata(): Returns the document’s metadata items, or None for a format without metadata extraction.
item.name / item.value: The name and the value of each property, such as title or author.
Example 3: Extract tables
Sometimes you need the data of a document rather than its text. get_tables() returns each table with its rows and cells.
importosfromgroupdocs.parserimportParser,Licensedefextract_tables():# Optionally set a licenselicense_path=os.path.abspath("./GroupDocs.Parser.lic")ifos.path.exists(license_path):License().set_license(license_path)# Open the document and print each table row by rowwithParser("./sample.pdf")asparser:tables=parser.get_tables()iftablesisNone:print("Table extraction isn't supported for this format")returnfortableintables:print("Table on page",table.page.index+1)forrowinrange(table.row_count):cells=[table[row,column].textforcolumninrange(table.column_count)]print(" | ".join(cells))if__name__=="__main__":extract_tables()
sample.pdf is the sample file used in this example. Click here to download it.