python提取pdf图片报错AttributeError: ‘Pixmap‘ object has no attribute ‘writePNG‘

编程入门 行业动态 更新时间:2024-10-17 23:35:57

python提取pdf图片<a href=https://www.elefans.com/category/jswz/34/1771188.html style=报错AttributeError: ‘Pixmap‘ object has no attribute ‘writePNG‘"/>

python提取pdf图片报错AttributeError: ‘Pixmap‘ object has no attribute ‘writePNG‘

 

import os
import re
import fitzdef extract_pic_info(filepath, pic_dirpath):"""提取PDF中的图片@param filepath:pdf文件路径@param pic_dirpath:要保存的图片目录路径@return:"""if not os.path.exists(pic_dirpath):os.makedirs(pic_dirpath)# 使用正则表达式来查找图片check_XObject = r"/Type(?= */XObject)"check_Image = r"/Subtype(?= */Image)"img_count = 0"""1. 打开pdf,打印相关信息"""pdf_info = fitz.open(filepath)# 1.16.8版本用法 xref_len = doc._getXrefLength()# 最新版本xref_len = pdf_info.xref_length()# 打印PDF的信息print("文件名:{}, 页数: {}, 对象: {}".format(filepath, len(pdf_info), xref_len - 1))"""2. 遍历PDF中的对象,遇到是图像才进行下一步,不然就continue"""for index in range(1, xref_len):# 1.16.8版本用法 text = doc._getXrefString(index)# 最新版本text =

更多推荐

python提取pdf图片报错AttributeError: ‘Pixmap‘ object has no attribute ‘writePNG‘

本文发布于:2024-03-07 10:08:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1717533.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   图片   python   pdf   AttributeError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!