需 Python 3.10 或更新版本;提取图片需额外安装 pip install 'pdfminer.six[image]';README 称对 PDF-1.7 规范仅做到「几乎」完整支持
pip install pdfminer.six
pdf2txt.py example.pdfREADME 未说明,纯 Python 实现,未提及 GPU 或显存要求
纯 Python 的 PDF 解析库,直接从 PDF 源码提取文本及其位置、字体和颜色信息
纯 Python 实现的 PDF 解析库,能从 PDF 中提取文本、布局和元数据,适合做文档解析、内容抽取和 RAG 数据预处理。
核心能力
- 直接从 PDF 源码提取文本,并获取精确位置、字体与颜色
- 支持输出 text、images、html 与 hOCR 多种格式
- 支持 CJK 语言与竖排书写
- 支持 Type1、TrueType、Type3、CID 多种字体
- 支持 RC4 与 AES 加密及 AcroForm 表单提取
容易踩的坑
- 20260107最新正式版2026-01-07 · 2026-01-07 13:29 UTC
- 202512302025-12-30 · 2025-12-30 15:49 UTC
查看更新说明
Security
- Eliminated arbitrary code execution vulnerability (CVE-2025-64512) by replacing pickle CMap storage with json - users with custom pickle CMaps can use
tools/convert_cmaps_to_json.pyto convert to JSON format (#1172))
- Eliminated arbitrary code execution vulnerability (CVE-2025-64512) by replacing pickle CMap storage with json - users with custom pickle CMaps can use
- 202512292025-12-29 · 2025-12-29 20:16 UTC
- 202512282025-12-28 · 2025-12-28 14:32 UTC
- 202512272025-12-27 · 2025-12-27 20:16 UTC
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
pdfminer.six
We fathom PDF
Pdfminer.six is a community maintained fork of the original PDFMiner. It is a tool for extracting information from PDF documents. It focuses on getting and analyzing text data. Pdfminer.six extracts the text from a page directly from the sourcecode of the PDF. It can also be used to get the exact location, font or color of the text.
It is built in a modular way such that each component of pdfminer.six can be replaced easily. You can implement your own interpreter or rendering device that uses the power of pdfminer.six for other purposes than text analysis.
Check out the full documentation on Read the Docs.
Features
- Written entirely in Python.
- Parse, analyze, and convert PDF documents.
- Extract content as text, images, html or hOCR.
- Support for PDF-1.7 specification (well, almost).
- Support for CJK languages and vertical writing.
- Support for various font types (Type1, TrueType, Type3, and CID) support.
- Support for extracting embedded images (JPG, PNG, TIFF, JBIG2, bitmaps).
- Support for decoding various compressions (ASCIIHexDecode, ASCII85Decode, LZWDecode, FlateDecode, RunLengthDecode, CCITTFaxDecode)
- Support for RC4 and AES encryption.
- Support for AcroForm interactive form extraction.
- Table of contents extraction.
- Tagged contents extraction.
- Automatic layout analysis.
How to use
-
Install Python 3.10 or newer.
-
Install pdfminer.six.
pip install pdfminer.six -
(Optionally) install extra dependencies for extracting images.
pip install 'pdfminer.six[image]' -
Use the command-line interface to extract text from pdf.
pdf2txt.py example.pdf -
Or use it with Python.
from pdfminer.high_level import extract_text text = extract_text("example.pdf") print(text)
Contributing
We welcome contributions! Whether you want to fix a bug, add a feature, or improve documentation, your help is appreciated.
Please note that as a community-maintained project with limited maintainer availability, the best way to get an issue resolved is to submit a pull request yourself.
To get started:
- Read CONTRIBUTING.md for setup instructions and coding standards
- Check out the open issues to find something to work on
- Join the discussion on Gitter if you have questions
Acknowledgement
This repository includes code from pyHanko ; the original license has been included here.