다양한 모듈을 설치해서 실행해봤지만, 실패한 것들이 많았고
(사용법을 몰라서 혹은 파일자체가 안맞아서)
최종적으로 사용한것은
pdftotext, PyMuPDF 2개
시도한것
pyPDF2, ocrmypdf, pdftotree, pdfminer
pdftotree깃헙
pdfminer깃헙
교훈
예전에 어떤 선생님께서 모듈,라이브러리 싸움이라고 하셨는데
pdf 관련해서 엄청나게 많은 모듈이 있는 걸 알게됬고, 이걸 바로바로 습득하는 게 진짜 능력이지 않나 싶다
물론 모듈 찾아내는 것 포함 (거의 반나절 다썼다)
설치법
pip install pdftotext
pip install PyMuPDF
pdftotext
fileReader = pdftotext.PDF(file)
page_sentences = fileReader[0]PyMuPDF
특이하게 fitz라는 이름으로 불러서 사용한다
공식문서
사용예시
import fitz
doc = fitz.open(file)
page = doc[0]
page_sentences = page.getText().split('\n')
추가 pypdfocr(Tesseract)
pdf이미지로부터 글자추출
# path 등록시켜야함
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'
'Python' 카테고리의 다른 글
| 주피터 노트북 확장 (Jupyter notebook nbextension) (0) | 2020.02.03 |
|---|
댓글