IRONSOFTWAREHOME
Extract Text
from ironpdf import *

# Load existing PDF document
pdf = PdfDocument.FromFile("content.pdf")

# Extract text from PDF document
all_text = pdf.ExtractAllText()

# Extract text from specific page in the document
page_2_text = pdf.ExtractTextFromPage(1)
pip install ironpdf
Extract Text

Extract Text

IronPDF for Python can extract the text content of a PDF document - either from the entire document at once or from individual pages - using the ExtractAllText and ExtractTextFromPage methods.

Getting Started

Load a PdfDocument from a file using PdfDocument.FromFile, then call the appropriate extraction method. Both methods return a Python string containing the extracted text.

Understanding the Code

  • PdfDocument.FromFile(path): Opens an existing PDF document from the specified file path. For password-protected files, pass the password as a second argument.
  • ExtractAllText(): Returns a single string containing the text extracted from all pages of the document, in page order.
  • ExtractTextFromPage(pageIndex): Returns the text content of a single page. The pageIndex argument is zero-based - pass 0 for the first page, 1 for the second, and so on.

Use Cases

Text extraction is useful for:

  • Search indexing - making PDF content searchable in a database or search engine.
  • Data parsing - extracting structured data such as invoice numbers, dates, or addresses from PDF reports.
  • Content verification - programmatically checking that generated PDFs contain the expected text.
  • Accessibility - converting PDF content to plain text for screen readers or downstream processing.
Learn to extract content from PDFs with IronPDF for Python!

Ready to Get Started?

Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999