首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在PPT中将图片设置为底层?

如何在PPT中将图片设置为底层?
EN

Stack Overflow用户
提问于 2019-10-29 11:54:56
回答 1查看 524关注 0票数 2

PPT的一张幻灯片里有文字和图片。我想将图片设置为底层/将文本设置为顶层并查看文本内容。如何做到这一点?

代码语言:javascript
复制
text_frame = shape.text_frame
text_frame.vertical_anchor = MSO_ANCHOR.TOP

text_frame = shape.text_frame
text_frame.vertical_anchor = MSO_ANCHOR.TOP
text_frame.paragraphs[0].runs[0].text = "text"

left = Inches(5)
height = Inches(5.5)
pic = slide.shapes.add_picture(img_path, left, top, height=height)

在PPT中让图片在底层,文本在顶层。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-29 12:57:21

幻灯片上的层将按照代码中的顺序显示。可以根据需要通过定义图层深度进行自定义。

代码语言:javascript
复制
from pptx import Presentation, shapes, slide
from pptx.util import Inches

img_path = 'image.png'

prs = Presentation()
blank_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(blank_slide_layout)

title = slide.shapes.title
subtitle = slide.placeholders[1]

title.text = "Hello, World!"
subtitle.text = "Welcome to python-pptx!"

left = Inches(1)
height = Inches(4)
width = Inches(6)
top = Inches(1)
picture = slide.shapes.add_picture(img_path, left, top, height=height)

# Using layer sequence number to customize the depth 
# sending the picture back in this case

slide.shapes._spTree.insert(2, picture._element)

prs.save('test.pptx')
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58601247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档