如何使用python-pptx增加由Python生成的PowerPoint演示文稿的幻灯片大小

6

我正在尝试将多个图表放入由Python生成的幻灯片中,但我需要幻灯片的尺寸更宽。我查阅了提供的文档,但可用文档并不多。

2个回答

10

pptx生成的幻灯片默认宽度为10英寸、高度为7.5英寸。以下代码可更改其默认幻灯片宽度和高度:

from pptx import Presentation
from pptx.util import Inches


prs = Presentation()
# set width and height to 16 and 9 inches.
prs.slide_width = Inches(16)
prs.slide_height = Inches(9)

4
我通过调整prs的宽度和高度大小成功解决了这个问题。
prs = Presentation()
prs.slide_width = 11887200
prs.slide_height = 6686550

1
我还发现可以导入英寸测量单位,而不是使用上述可能会令人困惑的测量点。 - K. Abhulimen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接