python批量生成ppt
利用pptx批量生成ppt,其实只是使用了模板,然后把图片变成固定格式,塞到固定位置
唯一值得说的是prs.slides.add_slide(prs.slide_layouts[3]),这个序号3是指打开的ppt所对应的模板的序号(而不是ppt的页数)
# -*- coding: utf-8 -*-
"""
Created on Wed May 6 14:07:51 2020@author: XX
"""from pptx import Presentation
from pptx.util import Cm
from pptx.shapes.picture import Picture
import os
import pandas as pd
preppt='C:\\Users\\验证.pptx'
#preppt=preppt.encode('gbk')
prs= Presentation(preppt)
print(len(prs.slide_layouts))
points=[2,3,4,5,6,7,8,9,10,11,12,13,40,42,45]
rsimage='C:\\Users\\图'
rslist = os.listdir(rsimage) #列出文件夹下所有的目录与文件
rslist=sorted(rslist,key=lambda x:int(x.split('-')[0]))
proimage='C:\\points\\LCLUPNG'
prolist = os.listdir(proimage) #列出文件夹下所有的目录与文件
for i in points:#下面的是处理pptcopied_slide = prs.slides.add_slide(prs.slide_layouts[3])img_path = os.path.join(rsimage,rslist[i-1])print(img_path)
# # 文件路径left, top, width, height= Cm(1), Cm(3), Cm(30), Cm(16)
# # 预设位置及大小pic= copied_slide.shapes.add_picture(img_path, left, top, height=height)for j in range(0,8):if j%2==0: #0,2,4,6copied_slide = prs.slides.add_slide(prs.slide_layouts[3])top, width, height= Cm(3), Cm(10), Cm(7.5) else:top, width, height= Cm(12), Cm(10), Cm(7.5) left=Cm(0.5)img_path = os.path.join(proimage,str(i)+'-方向'+str(j+1)+'-行列I.png')pic= copied_slide.shapes.add_picture(img_path, left, top, height=height)print(str(i)+'-方向'+str(j+1)+'-行列Index取值.png')left=Cm(14)img_path = os.path.join(proimage,str(i)+'-方向'+str(j+1)+'-线.png')pic= copied_slide.shapes.add_picture(img_path, left, top, height=height)print(str(i)+'-方向'+str(j+1)+'-延高线.png')left=Cm(24)img_path = os.path.join(proimage,str(i)+'-方向'+str(j+1)+'-延示Z0.png')pic= copied_slide.shapes.add_picture(img_path, left, top, height=height)print(str(i)+'-方向'+str(j+1)+'-延示Z0.png')
# # 在指定位置按预设值添加图片
#left= top= width= height= Inches(5)
## 预设位置及大小
#textbox= slide.shapes.add_textbox(left, top, width, height)
## left,top为相对位置,width,height为文本框大小
#textbox.text= 'this is a new textbox'
## 文本框中文字
#new_para= textbox.text_frame.add_paragraph()
## 在新文本框中添加段落
#new_para.text= 'this is second para in textbox'
## 段落文字
prs.save('C:\\Users\\test.pptx')
python批量生成ppt相关推荐
- Python工具源码,Python批量提取PPT文件中的图片
在办公场景当中,同样也有这样一个需求,那就是快速批量把PPT文件中的图片提取出来,毕竟一个个点击另存为太过于繁琐,以及耗费时间,前面本渣渣分享过如何应用Python批量提取PDF文件中的图片,而这一篇 ...
- python批量生成图片_利用Python批量生成任意尺寸的图片
实现效果 通过源图片,在当前工作目录的/img目录下生成1000张,分别从1*1到1000*1000像素的图片. 效果如下: 目录结构 实现示例 # -*- coding: utf-8 -*- imp ...
- python批量生成图_利用Python批量生成任意尺寸的图片
实现效果 通过源图片,在当前工作目录的/img目录下生成1000张,分别从1*1到1000*1000像素的图片. 效果如下: 目录结构 实现示例 # -*- coding: utf-8 -*- imp ...
- python ppt自动生成_实战 | Python自动生成PPT调研报告
原标题:实战 | Python自动生成PPT调研报告 原文: 全文约 3821 字,读完可能需要 5 分钟. 文/JSong @2017.02.28 在数据分析里面有一句话是说,80%的时间要用于数据 ...
- python生成随机个人信息——python批量生成随机信息
实验:python批量生成随机信息 这个实验很简单,直接上代码了~~ 一.常用汉字的Unicode编码 在unicode码中,汉字的范围是(0x4e00,0x9fbf),但是其中包含了很多生僻字或 ...
- python项目分析报告_实战 | Python自动生成PPT分析报告
原标题:实战 | Python自动生成PPT分析报告 在数据分析里面有一句话是说,80%的时间要用于数据清洗和整理,而我觉得理想的状态应该是把更多的把时间花在数据背后的洞察当中.去年11月在简书占了个 ...
- 直播系统源码,使用python批量生成原比例缩略图
直播系统源码,使用python批量生成原比例缩略图 from PIL import Imagedef smallPic():for i in range(1,51):filename = " ...
- python批量生成word复工证明
python批量生成word复工证明 近期不少企业开始复工,老板也给我安排让给所有员工开复工证明,借助python,轻松实现批量生成员工复工材料. 首先需要一个员工信息表格,如下表: 利用表格信息,批 ...
- Python批量调整PPT文档样式
Python批量调整PPT文档样式 在日常工作中,我们经常需要制作PPT文档来展示我们的工作成果或者进行汇报.但是,如果我们需要同时更改多张PPT的样式,手动修改会非常耗时且繁琐.此时,我们可以利用P ...
最新文章
- HMM(隐马尔科夫)用于中文分词
- 公司终于决定放弃微服务传统设计模式,全面拥抱 DDD!
- 设置CentOS7的grub密码
- bzoj 4753: [Jsoi2016]最佳团体
- 给指定服务器加路由,无线路由器如何给终端分配指定的IP地址?
- [导入]Asp.net中动态在中加入Scrpit标签
- 移动端实现文字轮播_移动端轮播图实现
- php-fpm哪里下载_如何在centos系统下找到php-fpm的位置 - 翟码农技术博客
- yslow各个指标含义
- Netty HashedWheelTimer 定时任务调用
- mysql+proxysql+keepalived实现高可用的数据库读写分离
- uploadify php使用,如何在ThinkPHP中使用Uploadify对图片进行上传
- 微信小程序实现智能识别名片
- Axure获取焦点和触发事件
- python中[::-1][1:2][1::2]的用法
- synology nfs_如何在Synology NAS桌面上创建,重新排列,组织和删除快捷方式
- 网易云音乐前端性能监控实践
- 五线舵机驱动程序_16路舵机驱动板程序使用说明
- 双系统安装deepin20_win10+deepin双系统安装方法(UEFI+GPT)
- Illustrator绘制时尚的圣诞老人插画教程