pdfprep
PDF 전처리 통합 도구 — 메타데이터 / 텍스트 파싱 / OCR / 표 추출 4가지 작업을 한 패키지로.
여러 PDF 처리 라이브러리(pypdf, pdfplumber, pymupdf, tesseract, paddleocr, camelot, tabula, layoutparser)를 일관된 인터페이스로 감싸서, 엔진별 결과를 한 번에 비교·선택할 수 있습니다.
설치
# 기본 (메타데이터 + 파싱만)
pip install pdfprep
# OCR 포함
pip install "pdfprep[ocr]"
# 표 추출 포함
pip install "pdfprep[table]"
# 전체
pip install "pdfprep[all]"
Python 버전별 지원 범위 (Windows 포함)
기능 Python 3.12 Python 3.13 / 3.14 기본 (메타데이터 · 파싱) ✅ ✅ OCR — tesseract ✅ ✅ OCR — paddleocr ✅ ⚠️ 설치 제외 표 — camelot · tabula ✅ ✅ 표 — layoutparser ✅ ⚠️ 설치 제외
paddleocr/paddlepaddle/layoutparser는 아직 Python 3.13+ 휠을 제공하지 않아, 3.13/3.14 환경에서는pip install시 자동으로 제외됩니다 (설치는 정상 완료). 해당 엔진을 호출하면 안내 메시지와 함께 건너뜁니다. paddle 계열이 필요하면 Python 3.12 를 사용하세요.
시스템 패키지 (해당 기능을 쓸 때만)
| 기능 | 패키지 | 설치 |
|---|---|---|
ocr (tesseract) |
tesseract 바이너리 + 언어 데이터 | sudo apt install tesseract-ocr tesseract-ocr-kor |
table (camelot lattice 모드) |
Ghostscript | sudo apt install ghostscript |
table (tabula) |
Java 런타임 | sudo apt install default-jre |
table (layoutparser) |
(없음 — paddlepaddle만 있으면 됨, 최초 실행 시 모델 자동 다운로드) | — |
빠른 시작
1. 메타데이터
from pdfprep import metadata
metadata.show_pdf_metadata("sample.pdf")
# 파일 크기 / 페이지 수 / Title / Author / 생성일 등 출력
2. 텍스트 파싱
from pdfprep import parsing
result = parsing.parse_pdf("sample.pdf", engine="pymupdf")
print(result["text"])
print(result["features"]) # 블록 수, 폰트, 이미지 수 등 엔진 특화 정보
지원 엔진: pypdf, pdfplumber, pymupdf
3. OCR
from pdfprep import ocr
result = ocr.ocr_pdf("scan.pdf", engine="tesseract")
print(result["text"])
print(result["features"]["평균 신뢰도(%)"])
지원 엔진: tesseract, paddleocr
4. 표 추출
from pdfprep import table
result = table.extract_tables("doc.pdf", engine="camelot")
for t in result["tables"]:
print(t["df"]) # pandas DataFrame
지원 엔진: camelot, tabula, layoutparser
CLI
설치 후 다음 명령들이 자동으로 등록됩니다:
pdfprep-metadata sample.pdf
pdfprep-parse sample.pdf pymupdf # 엔진 생략 시 전체 비교
pdfprep-ocr sample.pdf tesseract
pdfprep-table doc.pdf camelot
공통 API
모든 함수는 dict를 반환하며 공통 키가 같습니다:
{
"engine": "pymupdf", # 사용 엔진
"page_count": 3, # 페이지 수
"text": "...", # 통합 텍스트
"pages": ["...", ...], # 페이지별 텍스트
"features": {...}, # 엔진 특화 지표
}
표 추출은 추가로 table_count와 tables (DataFrame 또는 bbox 리스트)를 포함합니다.
엔진별 특징
| 모듈 | 엔진 | 강점 |
|---|---|---|
parsing |
pypdf | 가벼움. 목차/폼/주석/암호화 메타 |
parsing |
pdfplumber | 표·단어/문자 bbox·도형(선·사각형) |
parsing |
pymupdf | 빠름. 블록 구조 + 폰트/색상/이미지 메타 |
ocr |
tesseract | 빠름. 다국어 동시 인식. 단어별 신뢰도 |
ocr |
paddleocr | 딥러닝. 검출+인식 2단계. 라인 박스 + 신뢰도 |
table |
camelot | DataFrame + accuracy/whitespace 품질 지표 |
table |
tabula | DataFrame + 자동 헤더 인식 |
table |
layoutparser | 표 영역 bbox 검출(TableBank 모델). 셀 추출은 X |
요구 사항
- Python ≥ 3.12
- Linux 권장 (macOS·Windows에서도 동작하지만 시스템 패키지 설치 방법은 다름)
라이선스
MIT
Metadata
Release files for pdfprep 0.2.2
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 |
|---|---|---|---|---|
| pdfprep-0.2.2.tar.gz | 14.3 kB | Without provenance | Details for pdfprep-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pdfprep-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for pdfprep-0.2.2-py3-none-any.whl |
Total release size: 28.8 kB
Release files / pdfprep-0.2.2.tar.gz
| Download URL | pdfprep-0.2.2.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3c991d3e21bedf3e54b7729183c4bb190358f20f8cda50a9091343ec5d8f831
|
|
BLAKE2b-256 checksum How to use checksums |
41b503f180c4f1edc1c5952791c54d828989f8a5ca085f6c9c944e6acebbe621
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / pdfprep-0.2.2-py3-none-any.whl
| Download URL | pdfprep-0.2.2-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9e2101e1818d3658dc3a292b6f5e5cb26401a55bc0a263ce76ea6307ab369a6
|
|
BLAKE2b-256 checksum How to use checksums |
01ff6f5b9374dadc79e985f391df93fa95879cd54da4bb28040387ad5879ffd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for pdfprep 0.2.2
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.