scanny / python-pptx

Create Open XML PowerPoint documents in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set shink in sharp when text box overflow in Python pptx

MichaelPanwenjie opened this issue · comments

How to set indentation when text box overflow in Python pptx,
my codes is here:
def set_shrink_text_on_overflow(shape):
import pptx
print(pptx.version)
if shape.has_text_frame:
text_frame = shape.text_frame
try:
# text_frame.fit_text(max_size=18)
# text_frame.auto_size = MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE
# text_frame.word_wrap = True
text_frame.auto_size = MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE
text_frame.word_wrap = True
# time.sleep(0.5)
except Exception as e:
print(e)
pass
the codes setting correctlly but the ppt file still remain overflow,it should open ppt file manual,i want do it automatically
Can anyone can find the solution?

Continuing with the previous topic, why did you set text indentation but not respond?
You need to manually trigger the rendering engine. The reason is that the settings were modified to a ppt file, and the corresponding options were set correctly.
However, there is still a missing attribute fontScale like <a: normAutofit fontScale="90000"/>.
After manually triggering the rendering engine, a new attribute,<a: normAutofit fontScale="X"/>, was added to the corresponding XML file structure. The value of X is a scaled value that is not fixed, so it is necessary to add this attribute to automatically indent.

The author can consider this point by adding this attribute to the 'resize text to fit shape' setting in Python pptx. Correct X, thank you. Looking forward to the author's response and revisions