PPT中如何将图片设置到最底层?

How to set picture to bottom layer in PPT?

一张PPT幻灯片中有文字和图片。我想设置 Picture to bottom layer/set Text to top layer 并查看 Text 内容。怎么做?

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中让图片在底层,文本在顶层。

幻灯片上的图层将按照代码中的顺序显示。可以根据需要定义层深来定制。

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')