pdfminer.six

A pure-Python library for extracting text, layout, and metadata directly from PDF documents.

Library
PyPI
v20260107
7,018stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity4
Maintenance20
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture88
Code Quality85
Innovation75
Learning Curve90

pdfminer.six is a community-maintained fork of the original PDFMiner, focused on parsing and analyzing the text and layout of PDF documents. Rather than rasterizing pages or shelling out to an external binary, it walks the PDF’s own content streams to recover text, font, color, and exact coordinate information for every character on a page.

The library is built around a modular pipeline: a low-level PostScript-style parser and document model at the bottom, a resource-managed interpreter that walks the page’s content stream in the middle, and pluggable “device” and “converter” classes at the top that turn interpreted content into text, XML, HTML, hOCR, or a tree of layout objects. Because each stage is a swappable component, pdfminer.six is as useful as an extraction toolkit for building custom PDF-processing pipelines as it is as a drop-in extract_text() call.

It ships both a Python API (pdfminer.high_level.extract_text, extract_pages, extract_text_to_fp) and command-line tools (pdf2txt.py, dumppdf.py) for one-off extraction. Support spans encrypted PDFs (RC4/AES), CJK and vertical-writing fonts, embedded image extraction (JPEG, PNG, TIFF, JBIG2, bitmap), most of the standard PDF compression filters, and AcroForm/tagged-content extraction, making it one of the more complete pure-Python PDF parsing libraries available.

What You Get

  • High-level extract_text() and extract_pages() functions for quick, one-call text and layout extraction from a file path or file-like object
  • A composable pipeline of resource manager, interpreter, and device/converter classes for building custom extraction logic (text, XML, HTML, hOCR, tagged-content output)
  • Detailed layout analysis (LAParams) that groups characters into lines, boxes, and text groups with exact bounding-box coordinates, font, and color data
  • Command-line tools pdf2txt.py and dumppdf.py for extracting text or inspecting raw PDF object structure without writing any code
  • Support for encrypted PDFs (RC4 and AES), CJK/vertical-writing fonts, and embedded image extraction (JPEG, PNG, TIFF, JBIG2, bitmap) via an optional [image] extra
  • AcroForm interactive-form field extraction and PDF table-of-contents (outline) extraction

Common Use Cases

  • Extracting plain text from PDF reports, invoices, or academic papers for search indexing or downstream NLP
  • Building custom document-analysis pipelines that need precise character-level position, font, and color data (e.g. table or form-field detection)
  • Converting PDFs to structured HTML or XML for display or further processing
  • Feeding extracted text and layout into LLM-based document-understanding or RAG ingestion pipelines
  • Auditing or debugging malformed/unusual PDFs via the dumppdf.py low-level object dump

Under The Hood

Architecture pdfminer.six is layered as a classic parse-interpret-render pipeline: psparser.py/pdfparser.py tokenize the PDF’s PostScript-like object syntax into a document model (pdfdocument.py, pdftypes.py), pdfpage.py walks pages and their content streams, and pdfinterp.py’s PDFPageInterpreter executes each page’s content-stream operators against a PDFResourceManager (which owns font, colorspace, and XObject caching). Output is entirely decoupled from interpretation via a PDFDevice/PDFTextDevice abstraction in pdfdevice.py: the interpreter calls generic “paint” and “render text” methods, and concrete converter.py subclasses (TextConverter, HTMLConverter, XMLConverter, HOCRConverter, TagExtractor) or the PDFPageAggregator in layout.py turn those calls into text, markup, or a tree of LTPage/LTTextBox/LTChar layout objects. This separation means a new output format only requires a new device/converter, not changes to parsing or interpretation, and high_level.py wires the whole pipeline together behind a handful of simple functions.

Tech Stack The library targets Python 3.10+ with only two runtime dependencies — charset-normalizer for encoding detection and cryptography for AES/RC4 decryption of protected PDFs — plus an optional Pillow extra for image-format conversion. It uses setuptools with setuptools-scm for git-tag-based versioning, and uv for dependency management and dev workflows (lockfile checked into the repo). No web framework, database, or heavier runtime is involved; it’s a self-contained parsing library with two CLI entry-point scripts (pdf2txt.py, dumppdf.py) installed via script-files.

Code Quality The project enforces ruff for both linting (pycodestyle, pyflakes, isort, bugbear, simplify, comprehensions, and more) and formatting, and runs mypy in a notably strict configuration (disallow_untyped_defs, disallow_any_generics, no_implicit_optional, warn_return_any) specifically against the pdfminer.* module tree, giving the core library full static type coverage. Tests live under tests/ using pytest, covering the parser, layout engine, font handling, encoding, CMap security, and CLI tools, and CI (GitHub Actions) runs lockfile-freshness checks, formatting, linting, mypy, and the test suite across supported Python versions; a separate cifuzz.yml workflow runs continuous fuzzing via atheris against the parser, reflecting the project’s exposure to adversarial/malformed input as a document-parsing library.

What Makes It Unique Unlike most PDF text-extraction tools that either shell out to Poppler/MuPDF or rasterize pages, pdfminer.six is a from-scratch, pure-Python implementation of the PDF content-stream interpreter itself, giving it exact per-character position, font, and color data rather than approximate text blobs, and making its layout analysis engine (LAParams and the LT* object tree) usable as a general-purpose building block for downstream tools like table extraction or form parsing. Its device/converter abstraction also makes it unusually easy to plug in entirely custom output formats without touching the parsing internals — a design choice several other well-known Python PDF/text-extraction libraries build directly on top of.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search