pdf文档内容提取pdfplumber、PyPDF2


测试pdfplumber识别效果好些;另外pdf这两个如果超过20多页就没法识别了,结果为空

1、pdfplumber

复制代码
安装:

 pip install pdfplumber -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

代码:

复制代码
import pdfplumber

with pdfplumber.open(r"C:\Users\loong\Downloads\数字人研究报告.pdf") as pdf:
    num_pages = len(pdf.pages)
    print(num_pages)
    for page_num in range(num_pages):
        page = pdf.pages[page_num]
        text = page.extract_text()
        print(text)

原内容

识别结果:

2、PyPDF2

复制代码
安装:

pip install PyPDF2

代码:

复制代码
import PyPDF2
from tqdm import tqdm

pdftext = ""
with open(r"C:\Users\loong\Desktop\杰创\大模型\杰创智能.pdf", "rb") as pdfFileObj:
    pdfReader = PyPDF2.PdfReader(pdfFileObj)
    for page in tqdm(pdfReader.pages):
        pdftext += page.extract_text()

print(pdftext)
相关推荐
ElasticPDF-新国产PDF编辑器13 小时前
Vue 项目 PDF 批注插件库在线版 API 示例教程
前端·vue.js·pdf
ElasticPDF-新国产PDF编辑器14 小时前
Vue PDF Annotation plugin library online API examples
javascript·vue.js·pdf
Eiceblue15 小时前
.NET用C#在PDF文档中添加、删除和替换图片
开发语言·pdf·c#·.net·idea
开开心心就好15 小时前
解决 PDF 难题:批量处理、文档清理与自由拆分合并
java·学习·eclipse·pdf·word·excel·生活
ElasticPDF-新国产PDF编辑器15 小时前
Vue 项目使用 pdf.js 及 Elasticpdf 教程
javascript·vue.js·pdf
hello_simon17 小时前
PDF转换:在线将PDF转PPT并且可编辑文字图片,超快速转换软件,无需下载
pdf·html·excel·pdf转html·excel转pdf格式
ElasticPDF-新国产PDF编辑器17 小时前
HTML && jQuery PDF Annotation plugin library free online API examples
pdf·html·jquery
inxunoffice1 天前
批量将 Markdown 转换为 Word/PDF 等其它格式
pdf·word
iReachers1 天前
PDF转安卓APP软件, 支持加密添加一机一码, 静态密码, 保护APK版权使用说明和CSDN文库下载
android·pdf·pdf加密·pdf转app·pdf转apk·一机一码加密
曼岛_1 天前
CentOS 7 全流程部署Magic-PDF数据清洗工具(附GPU加速方案)
linux·pdf·centos