tomhu

from pptx import Presentation
from pptx.util import Inches,Pt

ppt = Presentation()
slide = ppt.slides.add_slide(ppt.slide_layouts[1]) #在ppt中插入一个幻灯片页

body_shape = slide.shapes.placeholders

title_shape = slide.shapes.title
title_shape.text = \'这里是标题\'
subtitle = slide.shapes.placeholders[1] #取出本页第二个文本框
subtitle.text = \'这里是文本框\'  #在第二个文本框中写入文字

new_paragraph = body_shape[1].text_frame.add_paragraph()
new_paragraph.text = \'新段落\'
new_paragraph.font.bold = True #文字加粗
new_paragraph.font.italic = True#文字斜体
new_paragraph.font.size = Pt(15) #文字大小
new_paragraph.font.underline = True #文字下划线


\'\'\'新加入一个文本框\'\'\'
left = Inches(6)
top = Inches(2)
width = Inches(3)
height = Inches(3)

textbox = slide.shapes.add_textbox(left,top,width,height)
textbox.text = \'这是新文本框\'
new_para = textbox.text_frame.add_paragraph()
new_para.text = \'这是文本框里面的第二段\'
ppt.save(r\'C:\Users\13375\Desktop\python\model.pptx\')


分类:

技术点:

相关文章:

  • 2022-02-23
  • 2021-08-26
  • 2021-07-22
  • 2021-12-27
  • 2021-04-22
  • 2021-07-09
  • 2021-04-12
  • 2021-10-06
猜你喜欢
  • 2021-08-24
  • 2021-12-27
  • 2021-08-15
  • 2021-10-08
  • 2021-04-16
  • 2021-12-04
  • 2021-12-04
相关资源
相似解决方案