Guide · Open source
How to use pdfplumber: extract text, tables and coordinates from PDFs
Updated · written with AI from the project's own documentation and checked against our catalogue data
pdfplumber is a Python library and command-line tool that reads PDF files and reports detailed information about each character, rectangle and line on a page. It can also extract text and tables from machine-generated PDFs. This guide shows you how to install it, open a PDF, pull out text and tables, and use its tools for inspecting layout.
Quick start
- 1Install the package. Run pip install pdfplumber in an environment running Python 3.10 or newer.
- 2Confirm the PDF is machine-generated. Check that the file has selectable text. The project works best on machine-generated PDFs rather than scanned images.
- 3Try the command line. Run pdfplumber on your file and redirect the output to a CSV or JSON file to see what the library detects.
- 4Open the PDF in Python. Use pdfplumber.open() in a with block and access the pages through the .pages list.
- 5Narrow the area. Use .crop(), .within_bbox() or .filter() to keep only the part of the page you need.
- 6Extract text and tables. Pull text and tables from the page, then save the results to CSV or JSON as your project requires.
- 7Debug unexpected output. Inspect object positions and fonts, and adjust laparams if the output does not match the page.
Install pdfplumber with pip
pdfplumber is installed from PyPI with pip. The library requires Python 3.10 or newer; the project's README lists tested versions from 3.10 through 3.14.
pip install pdfplumberUse the command line interface to export PDF data
The pdfplumber command reads a PDF and writes information about its objects to standard output. The default output is a CSV with one row for every character, line and rectangle in the file. Redirect the output to a file to save it.
Use the --format option to choose csv, json or text. The json format includes PDF-level and page-level metadata. The text format returns a plain-text representation of the PDF using layout mode. Use --pages to limit output to page ranges such as 1, 11-15, and --types to pick object types like char, rect, line, curve, image or annot.
- --format csv, json or text
- --pages for 1-indexed pages or ranges
- --types for char, rect, line, curve, image, annot and others
- --laparams to pass layout settings as a JSON string
- --precision to round floating-point numbers
pdfplumber background-checks.pdf > background-checks.csvOpen a PDF and read its pages in Python
Call pdfplumber.open() with a file path, a file object opened as bytes, or a file-like object. It returns a PDF object whose .pages list holds one Page object per page. Each Page exposes its page_number, width and height, plus lists such as .chars, .lines, .rects and .curves.
For password-protected files, pass the password keyword argument. To pass layout analysis settings to pdfminer.six, use the laparams argument. Use a with block so the file is closed when you finish.
- pdfplumber.open("file.pdf", password="test") for protected files
- pdfplumber.open("file.pdf", laparams={"line_overlap": 0.7}) for layout settings
- unicode_norm accepts NFC, NFD, NFKC or NFKD
- strict_metadata=True raises an error if metadata cannot be parsed; by default it is a warning
import pdfplumber
with pdfplumber.open("path/to/file.pdf") as pdf:
first_page = pdf.pages[0]
print(first_page.chars[0])Extract text and tables
Text and table extraction are listed as core features of the library. The README's extraction sections cover these tasks, and the Page class also offers methods to narrow the area you work on before extracting.
Use .crop() to keep objects that fall at least partly within a bounding box given as (x0, top, x1, bottom). Use .within_bbox() to keep only objects entirely inside the box, .outside_bbox() for objects entirely outside it, and .filter() to keep objects that pass your own test function.
with pdfplumber.open("path/to/file.pdf") as pdf:
page = pdf.pages[0]
region = page.crop((0, 100, page.width, 400))Inspect coordinates and debug results with visual debugging
Each object is a Python dict with properties such as page_number, text, fontname, size, upright, height and width for characters. Use these values to find exact positions when you need to locate text or lines on a page.
When an extraction looks wrong, the README highlights visual debugging as a feature for seeing what pdfplumber detected. It is a useful first step before adjusting settings such as laparams.
- Check fontname and size to tell headings from body text
- Compare character positions with line and rectangle positions to understand table structure
- Adjust laparams if characters are grouped or split unexpectedly
What people use it for
- Pulling tables from machine-generated report PDFs into Python data structures
- Converting report PDFs into CSV or JSON with the command line tool
- Finding the exact coordinates of text or lines on a page
- Debugging why a PDF extraction returns unexpected text, using visual debugging
Frequently asked questions
Is pdfplumber free to use?
pdfplumber is released under the MIT licence, as stated in the project's listing. The MIT licence permits use under its terms, so check the licence text if you have specific legal requirements.
What do I need to run pdfplumber?
You need Python 3.10 or newer. The README lists tested versions from 3.10 through 3.14, and you install the package with pip install pdfplumber.
Can pdfplumber read scanned PDFs?
The README says pdfplumber works best on machine-generated PDFs rather than scanned ones. It does not describe OCR support, so scanned pages may not yield usable text.
How does pdfplumber compare to PyPDF2, pypdf or pdfminer.six?
pdfplumber is built on pdfminer.six and focuses on detailed object positions plus text and table extraction. The README also has a comparison section, and the project lists PyPDF2, pypdf, pdfminer.six and Camelot as comparable tools.
Can pdfplumber create or edit PDFs?
No. The README covers reading and extraction only, so use a different library if you need to create or modify PDF files.
How do I open a password-protected PDF?
Pass the password keyword argument to pdfplumber.open(), for example pdfplumber.open("file.pdf", password="test").
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
pdfplumber suits Python developers and analysts who need text, tables or exact coordinates from machine-generated PDFs, and it is a good choice for debugging extraction problems. If you need to scan documents with OCR, create PDFs, or use a language other than Python, look at other tools.
Install options & downloads