python如何将pdf中的图片读取出来另存为pdf格式,或者直接将excel中数据转换为图片,
要求,不能够打开电脑中的wps或者office来截图,直接使用excel转图片的优先采纳,晚上五点半下班,下班后可能不能及时回复.直接粘贴代码上路就好,看到能有会采纳的
请用下面文件做代码测试,谢谢
PDF
EXCEL (文件太大,嫌弃登录麻烦的可以使用第二个)
第一个
https://gitee.com/xxhaadyq/image/raw/master/picture/163635776396.xlsx
第二个
提取后的图片示例
python 如何将pdf中图片读取出来另存为png格式
https://gitee.com/xxhaadyq/image/raw/master/picture/163635776396.pdf
登录 - Gitee.com
163635776396.xlsx
文件大小:2.1 M|
https://hhyq.lanzoui.com/i2Ap0wajhjc
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
笨鸟快飞呀 2021-11-08 17:16关注帅哥~
你的文件我打不开,但是我在我电脑上运行的代码如下,你可以参考修改一下试试,可以导出图片,不需要打开Excel
如果excel含有中文的话,可能会报字体不存在,因此添加对应的字体即可
打字不易,望采纳~import sys import io import matplotlib.pyplot as plt from pandas.plotting import table import pandas as pd sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8') plt.rcParams['font.sans-serif']=['SimHei'] # glyph 24230 字体添加 fig = plt.figure(figsize=(9, 10), dpi = 1400) ax = fig.add_subplot(111, frame_on=False,) ax.xaxis.set_visible(False) # hide the x axis ax.yaxis.set_visible(False) # hide the y axis datas = pd.read_excel('D:/test.xls') datas = datas.iloc[:, 0:] print(datas) table(ax, datas, loc='center') # where df is your data frame plt.savefig('photo.jpg')解决 无用评论 打赏 举报