Skip to main content

PDF 전처리 통합 도구 — 메타데이터, 텍스트 파싱, OCR, 표 추출

Project description

pdfprep

PyPI Python License

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_counttables (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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfprep-0.2.2.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdfprep-0.2.2-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file pdfprep-0.2.2.tar.gz.

File metadata

  • Download URL: pdfprep-0.2.2.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pdfprep-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c3c991d3e21bedf3e54b7729183c4bb190358f20f8cda50a9091343ec5d8f831
MD5 f101873f935ac763de263b4ddfbd595a
BLAKE2b-256 41b503f180c4f1edc1c5952791c54d828989f8a5ca085f6c9c944e6acebbe621

See more details on using hashes here.

File details

Details for the file pdfprep-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pdfprep-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pdfprep-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d9e2101e1818d3658dc3a292b6f5e5cb26401a55bc0a263ce76ea6307ab369a6
MD5 b0b40218920b600b57720ff29863dcf6
BLAKE2b-256 01ff6f5b9374dadc79e985f391df93fa95879cd54da4bb28040387ad5879ffd8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page