GroupDocs.Parser provides the functionality to extract text from documents with the highest quality.
The Accurate mode is the default text extraction mode, providing the best possible text quality from documents.
You can extract text from the entire document or from individual pages.
Prerequisites
Before you begin, ensure you have:
GroupDocs.Parser for Python via .NET installed
A valid license or trial
Sample documents for testing
Extract text from document
To extract text from the entire document in Accurate mode, use the get_text() method:
fromgroupdocs.parserimportParser# Create an instance of Parser classwithParser("./sample.pdf")asparser:# Extract text from the documenttext_reader=parser.get_text()# Check if text extraction is supportediftext_readerisNone:print("Text extraction isn't supported")else:# Print the extracted textprint(text_reader.read_to_end())
The following sample file is used in this example: sample.pdf
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]
Expected behavior: The method returns the entire document text as a str (which also answers read_to_end()), or None if text extraction is not supported for the document format.
Extract text from document page
To extract text from a specific page:
fromgroupdocs.parserimportParser# Create an instance of Parser classwithParser("./sample.pdf")asparser:# Check if text extraction is supportedifnotparser.features.text:print("Document doesn't support text extraction")else:# Get document infoinfo=parser.get_document_info()# Check if document has pagesifinfo.page_count==0:print("Document has no pages")else:# Iterate over pagesforpage_indexinrange(info.page_count):# Print page numberprint(f"\nPage {page_index+1}/{info.page_count}")# Extract text from the pagetext_reader=parser.get_text(page_index)# Print the page textiftext_readerisnotNone:print(text_reader.read_to_end())
The following sample file is used in this example: sample.pdf
Page 1/4
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
[TRUNCATED]