前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python为PPT文件进行截图操作的代码

Python为PPT文件进行截图操作的代码

原创
作者头像
用户8983410
修改2021-11-02 13:37:44
7030
修改2021-11-02 13:37:44
举报

下面的代码可以为powerpoint文件ppt进行截图,可以指定要截取的幻灯片页面,需要本机安装了powerpoint,可以指定截图的大小分辨率

代码语言:javascript
复制
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()</pre> 

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档