Python实现对PPT文件进行截图操作的方法
作者:重负在身 时间:2021-10-14 13:25:19
本文实例讲述了Python实现对PPT文件进行截图操作的方法。分享给大家供大家参考。具体分析如下:
下面的代码可以为powerpoint文件ppt进行截图,可以指定要截取的幻灯片页面,需要本机安装了powerpoint,可以指定截图的大小分辨率
import os
import comtypes.client
def export_presentation(path_to_ppt, path_to_folder):
if not (os.path.isfile(path_to_ppt) and os.path.isdir(path_to_folder)):
raise "Please give valid paths!"
powerpoint = comtypes.client.CreateObject("Powerpoint.Application")
# Needed for script to work, though I don't see any reason why...
powerpoint.Visible = True
powerpoint.Open(path_to_ppt)
# Or some other image types
powerpoint.ActivePresentation.Export(path_to_folder, "JPG")
#这里可以写成:
#Presentation.Slides[1].Export("C:/path/to/jpg.jpg","JPG",800,600);
powerpoint.Presentations[1].Close()
powerpoint.Quit()
希望本文所述对大家的Python程序设计有所帮助。
标签:Python,PPT,截图
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python批量处理csv并保存过程解析
2022-07-04 16:17:02
Python datatime库语法使用详解
2022-01-30 03:16:17
![](https://img.aspxhome.com/file/2023/6/83846_0s.png)
简单的PHP缓存设计实现代码
2023-10-25 19:58:08
Python及PyCharm下载与安装教程
2022-10-04 08:19:54
![](https://img.aspxhome.com/file/2023/3/90433_0s.png)
段正淳的css笔记(1)分类之间的横竖线
2007-11-01 21:47:00
![](https://img.aspxhome.com/file/UploadPic/200711/1/2007111215159211s.jpg)
Python面向对象编程基础解析(二)
2023-11-16 01:53:23
opencv python 图像轮廓/检测轮廓/绘制轮廓的方法
2022-08-13 06:54:59
![](https://img.aspxhome.com/file/2023/4/77864_0s.png)
社会化音乐:在夹缝中生出花来
2009-08-24 12:37:00
![](https://img.aspxhome.com/file/UploadPic/20098/24/0908-music-flower-01-18s.jpg)
Python+Pillow进行图形处理的示例详解
2021-08-03 22:42:34
![](https://img.aspxhome.com/file/2023/4/112044_0s.jpg)
python 如何去除字符串头尾的多余符号
2021-12-29 03:17:36
在VS2017中用C#调用python脚本的实现
2021-09-19 00:59:06
如何将服务器上的python代码通过QQ发送回传信息(附实现方法)
2022-04-24 04:27:08
![](https://img.aspxhome.com/file/2023/8/109518_0s.jpg)
Python中if __name__==‘__main__‘用法详情
2021-07-18 02:38:20
![](https://img.aspxhome.com/file/2023/1/67341_0s.jpg)
将不规则的Python多维数组拉平到一维的方法实现
2023-11-05 19:47:15
![](https://img.aspxhome.com/file/2023/2/63872_0s.png)
Python实现账号密码输错三次即锁定功能简单示例
2023-07-22 07:40:21
JS实现淡入淡出图片效果的方法分析
2023-08-24 08:45:44
python代码实现将列表中重复元素之间的内容全部滤除
2023-11-17 18:17:32
![](https://img.aspxhome.com/file/2023/5/63585_0s.png)
Python调用scp向服务器上传文件示例
2023-12-09 18:56:34
细品Dreamweaver MX 内建FW技术
2008-06-04 09:41:00
sql server 锁表语句分享
2012-02-12 15:49:20