pdftotext
Simple PDF text extraction
import pdftotext
# Load your PDF
with open("lorem_ipsum.pdf", "rb") as f:
pdf = pdftotext.PDF(f)
# If it's password-protected
with open("secure.pdf", "rb") as f:
pdf = pdftotext.PDF(f, "secret")
# How many pages?
print(len(pdf))
# Iterate over all the pages
for page in pdf:
print(page)
# Read some individual pages
print(pdf[0])
print(pdf[1])
# Read all the text into one string
print("\n\n".join(pdf))
Why
I needed to index a lot of PDF documents with Python. Existing solutions were slow, complicated, or both. That might not be true anymore!
Dependencies
Debian, Ubuntu, and friends
sudo apt install build-essential libpoppler-cpp-dev python3-dev
Fedora, Red Hat, and friends
sudo yum install gcc-c++ poppler-cpp-devel python3-devel
macOS
brew install poppler python
Install
pip install pdftotext
Metadata
Release files for pdftotext 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pdftotext-4.0.0.tar.gz | 112.3 kB | Without provenance | Details for pdftotext-4.0.0.tar.gz |
Release files / pdftotext-4.0.0.tar.gz
| Download URL | pdftotext-4.0.0.tar.gz |
|---|---|
| Size | 112.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c949f01bb0fea4560cc23e4b8b017188647d22f99a604a7ed3d09f72f43e634
|
|
BLAKE2b-256 checksum How to use checksums |
f4f4603a95657786fdbca99c3a65127507cb1a2d43c0c1c4d9f7a4680c56b61e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for pdftotext 4.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.