Python-100-Days/Day01-15/code/Day15/pdf2.py

19 lines
383 B
Python
Raw Normal View History

2018-09-25 22:49:21 +08:00
"""
读取PDF文件
Version: 0.1
Author: 骆昊
Date: 2018-03-26
"""
from PyPDF2 import PdfFileReader
with open('./res/Python课程大纲.pdf', 'rb') as f:
2019-05-03 21:17:36 +08:00
reader = PdfFileReader(f, strict=False)
print(reader.numPages)
if reader.isEncrypted:
reader.decrypt('')
current_page = reader.getPage(5)
print(current_page)
print(current_page.extractText())