1 import pdfplumber
2
3 with pdfplumber.open('test.pdf') as pdf:
4 #page_count = len(pdf.pages())
5 p0 = pdf.pages[0]
6 # 获取文本,直接得到字符串,包括了换行符【与PDF上的换行位置一致,而不是实际的“段落”】
7 #print(p0.extract_text())
8 # 获取本页全部表格,也可以使用extract_table()获得单个表格
9 for table in p0.extract_tables():
10 #得到的table是嵌套list类型,转化成DataFrame更加方便查看和分析
11 for line in table:
12 print(line)
13
14 #安装ImageMagick,地址在下面
15 #http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows
16 #https://blog.csdn.net/blmoistawinde/article/details/82051915