Dev/Python
파이썬 - PDF 파일 읽기
healthyryu
2022. 11. 14. 01:41
Python 으로 PDF 파일을 읽을 수 있게 도와주는 라이브러리 pdfplumber 를 사용했습니다. github 에서 Star 를 봤을때 충분히 사용할만하다고 판단이 되어서 사용합니다.

import pdfplumber
import os
# 스크립트가 있는 루트 폴더 경로
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
# 루트폴더에 들어있는 test.pdf 읽기
with pdfplumber.open(ROOT_DIR + "/test.pdf") as pdf:
for index in range(len(pdf.pages)):
print(pdf.pages[index].extract_text())
참고 : https://github.com/jsvine/pdfplumber#installation
GitHub - jsvine/pdfplumber: Plumb a PDF for detailed information about each char, rectangle, line, et cetera — and easily ext
Plumb a PDF for detailed information about each char, rectangle, line, et cetera — and easily extract text and tables. - GitHub - jsvine/pdfplumber: Plumb a PDF for detailed information about each ...
github.com
반응형