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]"

시스템 패키지 (해당 기능을 쓸 때만)

기능 패키지 설치
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.1.2.tar.gz (12.7 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.1.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pdfprep-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c4d05be05cd1221805519a44040be0b517c10e66ec6bc00390c33b21bf308cf3
MD5 f1d4bd57a73c95c11234536bc3cbf57d
BLAKE2b-256 6d1612194f54aa993b0fe6a4e32df451082a6421494cf14e05e98e25f4544d80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pdfprep-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 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.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 14134575b38d3d0414d280809de96633689cc7228793cc38cd5aca2f9a291d97
MD5 a067d44705a6b5d387b941bfd4535d77
BLAKE2b-256 ee3bf7ed3a0e0f39ba665492eec49452cc8d3ff144fe55903767381f63e04e8a

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