Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
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.
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.
def extract_text_pypdf(pdf_path: Path) -> str:
"""Fallback text extraction using pypdf."""
reader = PdfReader(pdf_path)
parts = []
for i, page in enumerate(reader.pages):
text = page.extract_text() or ""
if text.strip():
parts.append(f"--- Page {i + 1} ---\n{text}")
return "\n\n".join(parts)
PyMuPDF
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.
def _extract_tables_from_page(self, page: pymupdf.Page) -> str:
# ... if self.extract_tables is None:
return ""
import pymupdf
tables_list = list(
pymupdf.table.find_tables(page, **(self.extract_tables_settings or {}))
)
if tables_list:
if self.extract_tables == "markdown":
return _JOIN_TABLES.join([table.to_markdown() for table in tables_list])
elif self.extract_tables == "html":
# ... elif self.extract_tables == "csv":
return _JOIN_TABLES.join(
[
table.to_pandas().to_csv(
header=False,
index=False,
)
for table in tables_list
]
)
else:
raise ValueError(
f"extract_tables {self.extract_tables} not implemented"
)
return ""
pypdfium2
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.
import pypdfium2 as pdfium
pdf = pdfium.PdfDocument("./path/to/document.pdf")
page = pdf[0] # load a page
# Load a text page helpertextpage = page.get_textpage()
# Extract text from the whole pagetext_all = textpage.get_text_bounded()
def get_pdf_content(md5, filename, semantra_dir, force, silent):
converted_txt = os.path.join(semantra_dir, get_converted_pdf_txt_filename(md5))
position_index = os.path.join(semantra_dir, get_pdf_positions_filename(md5))
pdf = pdfium.PdfDocument(filename)
n_pages = len(pdf)
if force or not os.path.exists(converted_txt) or not os.path.exists(position_index):
positions = []
position = 0
# newline="" ensures pdfium's \r is preserved with open(
converted_txt, "w", newline="", encoding="utf-8", errors="ignore"
) as f:
for page_index in tqdm(
range(n_pages),
desc="Extracting PDF contents",
leave=False,
disable=silent,
):
page = pdf[page_index]
page_width, page_height = page.get_size()
textpage = page.get_textpage()
pagetext = textpage.get_text_range()
# ... position += f.write(pagetext)
position += f.write(LINE_FEED)
# ... return PDFContent(rawtext, filename, positions)
# ...
pdfminer.six
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.
@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
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.
def extract_tables(pdf_path: Path) -> list[dict]:
"""Extract all tables from a PDF. Returns list of {page, table_index, df}."""
results = []
table_settings = {
"vertical_strategy": "lines",
"horizontal_strategy": "lines",
"snap_tolerance": 3,
}
with pdfplumber.open(pdf_path) as pdf:
for page_num, page in enumerate(pdf.pages, 1):
# Try structured line-based detection first tables = page.extract_tables(table_settings)
if not tables:
# Fall back to text-based detection tables = page.extract_tables()
for t_idx, table in enumerate(tables):
if not table or len(table) < 2:
continue
# ... df = pd.DataFrame(rows, columns=header)
results.append({
"page": page_num,
"table_index": t_idx + 1,
"df": df,
})
return results
def lazy_parse(self, blob: Blob) -> Iterator[Document]:
"""Lazily parse the blob."""
import pdfplumber
with blob.as_bytes_io() as file_path:
doc = pdfplumber.open(file_path) # open document
yield from [
Document(
page_content=self._process_page_content(page)
+ "\n"
+ self._extract_images_from_page(page),
metadata=dict(
{
"source": blob.source,
"file_path": blob.source,
"page": page.page_number - 1,
"total_pages": len(doc.pages),
},
**{
k: doc.metadata[k]
for k in doc.metadata
if type(doc.metadata[k]) in [str, int]
},
),
)
for page in doc.pages
]
docling
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.
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[...]"
def read_document(input_path: str, fmt: str, max_chars: int, pages_str: str | None) -> str:
"""Convert document via docling and extract content."""
converter = build_converter()
result = converter.convert(input_path)
doc = result.document
if fmt == "markdown":
content = doc.export_to_markdown()
else:
content = doc.export_to_text()
# ... if max_chars > 0 and len(content) > max_chars:
content = content[:max_chars] + f"\n\n... [truncated, total {len(content)} chars]"
return content
camelot
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.
def _read_pdf_tables(path, start_row, end_row):
import pandas as pd
import camelot
if path.startswith(("http://", "https://", "ftp://")) and " " in path:
path = web.url_encode(path)
dataframes = []
for table in camelot.read_pdf(path, pages="all", suppress_stdout=False): # type: ignore
dataframe = table.df
if start_row:
dataframe = dataframe.iloc[start_row:]
if end_row:
dataframe = dataframe.iloc[:end_row]
if isinstance(dataframe.columns, pd.RangeIndex):
dataframe.columns = dataframe.iloc[0]
dataframe = dataframe.iloc[1:]
dataframe.columns = [" ".join(column.replace("\n", "").split()) for column in dataframe.columns]
dataframes.append(NDF(None, dataframe))
return dataframes
liteparse
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.
def _parse_in_process(self, document: FetchedDocument, config: dict) -> str:
try:
from liteparse import LiteParse
except Exception as e:
raise RuntimeError("LiteParse is not installed") from e
parser = LiteParse(**self._liteparse_kwargs(config))
with document.local_file() as file_path:
result = parser.parse(file_path)
text = getattr(result, "text", "") or ""
if not text.strip():
raise ValueError("LiteParse returned no text")
return text
def process(self, path: str | os.PathLike) -> Document:
# ... p = Path(path)
if not p.exists():
raise FileNotFoundError(f"File not found: {path}")
suffix = p.suffix.lower()
if suffix not in self.SUPPORTED_TYPES:
raise ValueError(
f"Unsupported file type: {suffix}. Supported types: {sorted(self.SUPPORTED_TYPES)}"
)
logger.debug(f"Processing file with LiteParse: {path}")
result = self.parser.parse(str(p))
content = result.text if result and result.text is not None else ""
logger.info(
f"LiteParse processing complete: extracted {len(content)} characters from {path}"
)
doc = Document(content=content)
self._set_source_filename(doc, path)
return doc
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.