Python/문서 데이터 분석
[Python] [PyPDF2] PDF 파일 정보 추출
데이터 세상
2022. 1. 10. 13:15
728x90
반응형
PyPDF2
https://pythonhosted.org/PyPDF2/
PyPDF2 Documentation — PyPDF2 1.26.0 documentation
pythonhosted.org
PyPDF2 설치
pip install PyPDF2
PyPDF2를 이용한 파일 정보 추출
from PyPDF2 import PdfFileReader
pdfreader = PdfFileReader("sample.pdf")
# Document Information
print(pdfreader.documentInfo)
# Total page number
print(f"Number of pages: {pdfreader.numPages}")
# Get text from the first page
print(pdfreader.getPage(0).extractText())
결과
{
'/Title': 'PowerPoint 프레젠테이션',
'/Author': 'Author',
'/CreationDate': "D:20220110111620+09'00'",
'/ModDate': "D:20220110111620+09'00'",
'/Producer': 'Microsoft® PowerPoint® 2013',
'/Creator': 'Microsoft® PowerPoint® 2013'
}
Number of pages: 1
:
1
2
3
1_1
2_1
3_1
1_2
2_2
3_2
1_3
2_3
3_3
※ 한글 텍스트가 정상 추출되지 않는다.
728x90
반응형