Python PDF libraries

Updated Nov 2026

Python PDF libraries read, edit, and extract content from PDF files. A PDF stores text as characters placed at positions on a page, with no record of paragraphs or tables. These libraries pull text and tables out of invoices, reports, and research papers for search indexes and AI pipelines.

Popularity

pypdf has the most installs, while docling has the most GitHub stars.

LibraryMonthly downloadsStarsLast releaseLicense
pypdf
126.0M
10.3KNov 2026BSD-3-Clause
PyMuPDF
83.2M
11.1KNov 2026AGPL-3.0
pypdfium2
61.9M
857Nov 2026BSD-3-Clause
pdfminer.six
53.2M
7.0KJan 2026MIT
pdfplumber
40.7M
10.9KJun 2026MIT
docling
2.9M
70.3KNov 2026MIT
camelot
721.6K
3.8KJun 2026MIT
liteparse
360.4K
13.0KNov 2026Apache-2.0
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryExtracts tables as rowsOCR for scanned pagesRetains layout and coordinatesExtracts imagesOutput formats
pypdfUnsupportedUnsupportedBuilt-inVia pluginText, PDF
PyMuPDFBuilt-inVia pluginBuilt-inBuilt-inJSON
pypdfium2UnsupportedUnsupportedBuilt-inBuilt-inPDF
pdfminer.sixUnsupportedUnsupportedBuilt-inVia pluginHTML, Text, XML
pdfplumberBuilt-inUnsupportedBuilt-inBuilt-inJSON, CSV, Text
doclingBuilt-inVia pluginBuilt-inBuilt-inMarkdown
camelotBuilt-inVia pluginBuilt-inUndocumentedMarkdown, JSON
liteparseVia pluginVia pluginBuilt-inBuilt-inMarkdown, JSON
Built-inVia pluginNot supportedNot documented

Libraries and code examples

pypdf is a PDF library written entirely in Python. Installing it needs no compiler or system packages. PdfReader opens a file, and calling extract_text on one of its pages returns that page's text. The same package splits, merges, crops, and rotates pages, reads metadata, and adds or removes passwords. Files encrypted with AES need the optional pypdf[crypto] extra.

Downloads / mo
126.0M
Stars
10.3K
Last release
7.0.0, Nov 2026
License
BSD-3-Clause

Strengths

  • Text and metadata in one call. PdfReader gives each page's text and the document's title, author, and dates.
  • Reads form values. Returns what was typed into fillable PDF forms.
  • Pure Python install. pip install works anywhere, with no compiler or system packages.

Limitations

  • Slower than PyMuPDF. Extracts text more slowly and keeps little of the page layout.
  • No text from scanned pages. Scanned pages need OCR software, such as Tesseract, first.

Quickstart

From the README
$ pip install pypdf
from pypdf import PdfReader

reader = PdfReader("example.pdf")
number_of_pages = len(reader.pages)
page = reader.pages[0]
text = page.extract_text()

pypdf examples

From open-source projects on GitHub

Extracts text from each page of a PDF with pypdf and returns one document per page or one for the whole file.

Extracts text from every page with PdfReader and labels each page's text with its page number.

PyMuPDF is the Python binding for MuPDF, a PDF rendering engine written in C. pymupdf.open loads a document, and each page's get_text method returns its text, or, with the "dict" option, every block and line with its font, color, and position. The same library renders pages to images, redacts, merges, and splits documents, and exports Markdown or JSON for LLM pipelines. Compared with pypdf, PyMuPDF keeps word positions and also opens XPS, EPUB, and image files.

Downloads / mo
83.2M
Stars
11.1K
Last release
2.1, Nov 2026
License
AGPL-3.0
Runs on
ONNX Runtime

Strengths

  • Text with positions. Returns each word with its coordinates, plus images and page renders.
  • Finds tables too. page.find_tables() returns each table's rows without a second library.
  • Fast on large files. About 0.1s per document in the py-pdf benchmark.

Limitations

  • OCR engine installed separately. Scanned pages need an OCR engine, either RapidOCR from pip or Tesseract as a system program. The README recommends RapidOCR.
  • Source build without a wheel. On a platform with no prebuilt wheel, pip compiles the package, which needs a C and C++ toolchain.
  • Text can come out of order. Default output follows file order, not always reading order.

Quickstart

From the README
$ pip install pymupdf
import pymupdf

doc = pymupdf.open("document.pdf")
for page in doc:
    print(page.get_text())

PyMuPDF examples

From open-source projects on GitHub

Extracts the text of each PDF page with PyMuPDF and returns one document per page.

Finds tables on a PDF page with PyMuPDF's find_tables and returns them as Markdown, HTML or CSV.

pypdfium2 is a Python binding to PDFium, an open source library for rendering, inspecting, and editing PDFs. Prebuilt wheels for most platforms bundle PDFium itself. A page's get_textpage method loads its text layer: get_text_bounded then returns the text inside a rectangle, such as one field on an invoice, and search finds a string on the page. render turns a page into a bitmap that converts to a Pillow image or a NumPy array.

Downloads / mo
61.9M
Stars
857
Last release
5.15.1, Nov 2026
License
BSD-3-Clause

Strengths

  • Prebuilt binaries. Wheels include PDFium for most platforms, so no compiler is needed.
  • Fastest plain text. Ranked first in the py-pdf benchmark, at about 0.1s per document.
  • Reads one area of a page. get_text_bounded() returns only the text inside a box, such as one invoice field.

Limitations

  • Loses column layout. Output doesn't keep the spacing that lines up columns.
  • System PDFium elsewhere. On a platform without a prebuilt wheel, setup looks for a system copy of PDFium or builds PDFium from source.

Quickstart

From the README
$ pip install pypdfium2
import pypdfium2 as pdfium

pdf = pdfium.PdfDocument("./path/to/document.pdf")
page = pdf[0]  # load a page

# Load a text page helper
textpage = page.get_textpage()

# Extract text from the whole page
text_all = textpage.get_text_bounded()

pypdfium2 examples

From open-source projects on GitHub

Extracts text from a page range with PDFium's get_text_bounded, or from a cropped region of each page.

Extracts each page's text through PDFium's text page API and records page sizes and character offsets for later lookup.

pdfminer.six is a community-maintained fork of PDFMiner, written entirely in Python, that reads text directly from the instructions inside a PDF file. extract_text from pdfminer.high_level returns a file's text in one call, and the layout analysis underneath reports the exact position, font, and color of each piece of text. Output formats include plain text, HTML, and hOCR, an OCR layout format, and the parser handles Chinese, Japanese, and Korean, including vertical writing. pdfplumber builds its table extraction on this library.

Downloads / mo
53.2M
Stars
7.0K
Last release
20260107, Jan 2026
License
MIT

Strengths

  • Every character's position. Gives the position of each character and text box, for custom layout code.
  • Reads Chinese, Japanese, and Korean. Handles CJK text, including vertical writing.
  • Exports HTML. Writes pages as text, HTML, or hOCR, an OCR layout format.

Limitations

  • More code to write. Joining characters into lines, columns, and tables takes custom code.
  • Slow on large files. About 3.5s per document in the py-pdf benchmark, against 0.1s for PyMuPDF.
  • Images need an extra. Extracting embedded images needs the pdfminer.six[image] extra.

Quickstart

From the README
$ pip install pdfminer.six
from pdfminer.high_level import extract_text

text = extract_text("example.pdf")
print(text)

pdfminer.six examples

From open-source projects on GitHub

Extracts text from PDF bytes held in memory with pdfminer.six's extract_text.

pdf.py · op_pdf_extract() · pushed May 2026
@defop('pdf-extract', 0, 0)
def op_pdf_extract(aipl, pdfdata:bytes) -> str:
    'Extract contents of pdf to value.'
    from pdfminer.high_level import extract_text
    from io import BytesIO
    s = BytesIO(pdfdata)
    return extract_text(s)

pdfplumber opens a PDF and reports every character, line, and rectangle on each page with its position. extract_tables returns each table on a page as rows of cells, and crop limits any call to one area, such as the transaction list on a bank statement. to_image draws what the library found onto a picture of the page, which helps when tuning the table settings. The library is built on pdfminer.six.

Downloads / mo
40.7M
Stars
10.9K
Last release
0.11.10, Jun 2026
License
MIT

Strengths

  • Tables as rows. extract_tables() returns each table as a list of rows.
  • Reads one area of a page. Crop to a box to read one section, such as a statement's transactions.
  • Shows what it found. Draws the detected text, lines, and tables on a page image for debugging.

Limitations

  • Merges two-column text. Crop each column first, or lines from both columns run together.
  • No OCR for scans. Reads the text layer of machine-generated PDFs, so scanned pages need OCR first.
  • Slowest at plain text. About 5.6s per document, the slowest in the py-pdf benchmark.

Quickstart

From the README
$ pip install pdfplumber
import pdfplumber

with pdfplumber.open("path/to/file.pdf") as pdf:
    first_page = pdf.pages[0]
    print(first_page.chars[0])

pdfplumber examples

From open-source projects on GitHub

Extracts every table in a PDF with pdfplumber's extract_tables and turns each one into a pandas DataFrame.

Extracts text from each PDF page with pdfplumber and attaches page numbers and file metadata.

Docling converts PDFs, Office files, HTML, images, audio, and other formats into one document model, DoclingDocument, that records page layout, reading order, tables, formulas, and code. DocumentConverter runs the conversion from Python. From a terminal, the docling command does the same. Exports include Markdown, HTML, and lossless JSON, and integrations exist for LangChain, LlamaIndex, Crew AI, and Haystack. Scanned pages go through OCR. Every step runs on the local machine.

Downloads / mo
2.9M
Stars
70.3K
Last release
2.149.0, Nov 2026
License
MIT

Strengths

  • Keeps reading order and tables. Detects layout, tables, and formulas, and runs OCR on scanned pages.
  • Exports Markdown or JSON. Writes Markdown, HTML, or JSON, ready to split into chunks for an LLM.

Limitations

  • GPU speeds up models. The layout and table models run on the CPU unless the accelerator options select a CUDA GPU.
  • Slower than plain extractors. Runs models on every page, so it takes longer than pypdf.
  • Large install. The layout and table models come with the package, which can exceed a size-limited serverless function.

Quickstart

From the README
$ pip install docling
from docling.document_converter import DocumentConverter

source = "https://arxiv.org/pdf/2408.09869"  # a document via a local path or URL
converter = DocumentConverter()
result = converter.convert(source)
print(result.document.export_to_markdown())  # output: "## Docling Technical Report[...]"

docling examples

From open-source projects on GitHub

Converts PDFs with Docling's DocumentConverter and exports each one as Markdown or JSON text.

Converts a document with Docling and exports it as Markdown or plain text, trimmed to a character limit.

Camelot extracts tables from PDFs and returns each one as a pandas DataFrame. camelot.read_pdf takes a file path, URL, or bytes and picks a parser through its flavor argument: lattice follows ruled lines, stream uses the whitespace between columns, and auto chooses one. Each table comes with accuracy and whitespace scores and exports to CSV, JSON, Excel, HTML, Markdown, or SQLite. The default install bundles PDFium, so no system packages are needed.

Downloads / mo
721.6K
Stars
3.8K
Last release
2.0.0, Jun 2026
License
MIT

Strengths

  • Tables as DataFrames. Each table comes back as a pandas DataFrame and exports to CSV or Excel.
  • Ruled and borderless tables. Use lattice for tables with lines and stream for tables without them.

Limitations

  • Struggles with merged cells. Merged or multi-line cells don't fit a rectangular table.
  • Scans need extras. The built-in parsers need selectable text. Scanned PDFs need the camelot-py[ml,ocr] extras and flavor="ml", a neural table model with OCR.

Quickstart

From the docs
$ pip install camelot-py
import camelot
tables = camelot.read_pdf('foo.pdf')
tables
tables.export('foo.csv', f='csv', compress=True) # json, excel, html, markdown, sqlite
tables[0]
tables[0].parsing_report
tables[0].to_csv('foo.csv') # to_json, to_excel, to_html, to_markdown, to_sqlite
tables[0].df # get a pandas DataFrame!

camelot examples

From open-source projects on GitHub

Extracts tables from chosen PDF pages with camelot.read_pdf and turns each table into a text document.

Reads every table in a PDF with camelot.read_pdf and cleans each DataFrame's rows and column names.

LiteParse parses PDFs on the local machine into text with bounding boxes, using PDFium for the text layer and a bundled copy of Tesseract for scanned pages. The core is written in Rust, with bindings for Python, Node.js, and the browser through WebAssembly. Output comes as Markdown, JSON, or layout-preserving text, and the parser also renders page screenshots for LLM agents. Other OCR engines, such as EasyOCR or PaddleOCR, plug in over HTTP.

Downloads / mo
360.4K
Stars
13.0K
Last release
2.18.0, Nov 2026
License
Apache-2.0

Strengths

  • Text with positions. Returns text with bounding boxes, layout-kept text, or page screenshots.
  • Fast on large files. Parses about two to five milliseconds per page.
  • OCR included. Tesseract ships inside the package, so scanned pages work with no setup.

Limitations

  • Flattens complex tables. Tables with multi-row headers come out as aligned text, not rows.
  • Complex documents. The README points dense tables, multi-column layouts, charts, handwriting, and scans to LlamaParse, the hosted parser from the same team.

Quickstart

From the README
$ pip install liteparse
from liteparse import LiteParse

parser = LiteParse()
result = parser.parse("document.pdf")
print(result.text)
print(f"Source document pages: {result.total_pages}")

# Access structured data
for page in result.pages:
    print(f"Page {page.page_num}: {len(page.text_items)} text items")

liteparse examples

From open-source projects on GitHub

Extracts text from a fetched document with LiteParse and raises an error when no text comes back.

Extracts text from a document file with LiteParse and wraps it in a Document.

FAQ

PyMuPDF is the best first library to try: it returns text with word positions, finds tables, and renders pages, and it averaged 0.1s per document in the py-pdf benchmark. pypdf is the easiest install, pdfplumber and camelot are stronger on tables, and docling turns whole documents into Markdown.

Open the file with pypdf's PdfReader and call extract_text() on each page, after a plain pip install pypdf. pdfminer.six does the same for a whole file with one call, extract_text("file.pdf"). Neither library reads scanned pages, which need OCR first.

liteparse is the easiest, with Tesseract, an open-source OCR engine, bundled inside the package. docling runs OCR as part of its layout pipeline, and PyMuPDF reads scanned pages once Tesseract is installed separately. pypdf, pdfminer.six, pdfplumber, and pypdfium2 return little or no text from a scanned page.

camelot returns each table as a pandas DataFrame and exports it to CSV or Excel. pdfplumber's extract_tables() returns each table as a list of rows, and PyMuPDF's page.find_tables() does the same without a second library. camelot needs selectable text, so a scanned table needs OCR first. See Capabilities.

docling converts a whole PDF to Markdown, HTML, or JSON with headings, reading order, and tables kept, ready to split into chunks for an LLM. liteparse also writes Markdown, and camelot exports single tables to Markdown.

For tables and fine layout control, yes; for speed, no. pdfplumber crops a page to one area and draws what it detected for debugging, while PyMuPDF averaged 0.1s per document against 5.6s for pdfplumber in the py-pdf benchmark. Both return text with positions.

PyMuPDF extracts text faster and keeps more of the layout, at 0.1s per document against 1.8s for pypdf in the py-pdf benchmark. pypdf is pure Python, so it installs with no compiler, and it uses the BSD-3-Clause license, while PyMuPDF uses AGPL-3.0.

For coding agents

Found your PDF library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official