能否让PowerPoint 2013自动适应文本?我正在使用python-pptx,并可以设置自动调整选项,但最初不起作用。如果我调整文本框的大小或随后更改“换行”等设置,则自动调整大小将起作用。但是,我无法在python-pptx中完成此操作。我需要选项在添加文本时立即生效。
我认为这是PowerPoint中的错误,Microsoft不打算解决,但希望我错了。
这是一段简单的代码,可以将文本放入文本框中并自动换行,无需调整文本框大小。希望这能有所帮助。
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中找到。