如何将Powerpoint转换为autofit-tex

2024-10-01 05:05:50 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有可能让powerpoint2013自动调整文本?我使用的是python pptx,我可以将选项设置为autofit,但最初它不起作用。如果我调整文本框的大小或随后更改了“换行”之类的设置,则自动调整工作正常。但是,我不能从python pptx做到这一点。我需要第一次添加文本的选项。在

我认为这是PowerPoint中的一个错误,微软不打算修复,但希望我错了。在


Tags: 文本选项错误文本框pptxpowerpointautofitpowerpoint2013
1条回答
网友
1楼 · 发布于 2024-10-01 05:05:50

下面是一个简单的代码,它可以在文本框中包装文本,而不需要调整文本框的大小。我希望这有帮助。在

from pptx import Presentation
from pptx.util import Inches

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

textBox = slide.shapes.add_textbox(Inches(3.5), Inches(0.5),Inches(3), Inches(3.0))
textFrame = textBox.text_frame
textFrame.word_wrap = True
textParagraph = textFrame.add_paragraph()
textParagraph.text = "This is a word_wrap example. The words  are wrapped within the textframe"

prs.save("C:\OSGeo4W\GPSPictureManager\Tests\PptxWordWrapTest.pptx")#specify path for new pptx file

更多详细信息请参见http://python-pptx.readthedocs.io/en/latest/api/text.html#textframe-objects

相关问题 更多 >