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

 

 

반응형

'Dev > Python' 카테고리의 다른 글

LangChain 설치 관련  (0) 2023.10.10
vscode 에서 Python 사용에 대한 공부  (0) 2022.10.30
웹스크래핑 - Web Scraping  (0) 2022.10.02
파이썬 알고리즘 - 삽입정렬  (0) 2017.08.20
파이썬 알고리즘 - 패턴문제  (0) 2017.07.17