Text Frame's Autofit Type Property Is Not Working Properly in Python

Working with - Aspose.Slides Python library.
When I try to resize shape to fit text using the [TextFrameFormat.AutoFitType Property] on a text box then the height of the output text box is not wrapped properly.

Example:
When I try to use this code snippet on a pptx file, then the output appears as visible in attached in screenshot(shape_fit_via_aspose file)

with slides.Presentation("input.pptx") as presentation:

    presentation.slides[0].shapes[0].text_frame.text_frame_format.wrap_text = slides.NullableBool(True)
    presentation.slides[0].shapes[0].text_frame.text_frame_format.autofit_type = slides.TextAutofitType.SHAPE

    presentation.save("output.pptx", slides.export.SaveFormat.PPTX)

However, when we try to use the powerpoint application to apply the same “Resize shape to fit text” setting on the text box, then the output appears as visible in screenshot(shape_fit_via_powerpoint file).

shape_fit_via_aspose.jpg (113.7 KB)
shape_fit_via_powerpoint.jpg (116.0 KB)

@Prezent_Inc,
Thank you for contacting support. I am working on the issue and will get back to you soon.

@Prezent_Inc,
Please share the following files and information:

  • input and output presentation files (you can zip the files and upload an archive here)
  • Aspose.Slides version you used

Hello Andrey,
Hope following helps -
Aspose.Slides version = 24.6.0
Input pptx and Python script.zip (30.5 KB)

@Prezent_Inc,
Thank you for the presentation file. With Aspose.Slides for Python 24.6, I was unable to reproduce the problem you described. My result: output.zip (27.7 KB). Unfortunately, we need more information on how to reproduce the problem on our end.

Please also note that the wrap_text property should be used like this:

presentation.slides[0].shapes[0].text_frame.text_frame_format.wrap_text =
    slides.NullableBool.TRUE

aspose_issue.zip (56.3 KB)

Hi Andrey

Can you check for these input and output files? We are still facing the same issue as described previously.

Thank you.

@Prezent_Inc,
I tested the problem and got the same results. Please also note that the “input.pptx” file you provided and the file you provided above are identical.

We are still facing issues when we are trying to use “Resize shape to fit text” option for a text box via aspose library.
Attached is a powerpoint file “resize_bug.pptx” which contains one text box (where the text is overflowing from the text box)
I opened this presentation via aspose and used the commands below:

presentation.slides[0].shapes[0].text_frame.text_frame_format.autofit_type=slides.TextAutofitType.NONE
presentation.slides[0].shapes[0].text_frame.text_frame_format.autofit_type=slides.TextAutofitType.SHAPE

and saved the presentation after that. The text box still did not resize properly to fit the text.
The output presentation is attached by the name “output.pptx”.

Please help us with the same.
NOTE: When I use the same option from the powerpoint application, then the text box is resized properly and fits in all the text. But the same is not happening via aspose.
Attachments.zip (44.2 KB)

@Prezent_Inc,
Thank you for the message. I need some time to check the issue. I will get back to you soon.

@Prezent_Inc,
Unfortunately, I was unable to reproduce the problem you described with Aspose.Slides for Python 24.6 and 25.2. I used the following code example:

with slides.Presentation("resize_bug.pptx") as presentation:
    shape = presentation.slides[0].shapes[0]
    shape.text_frame.text_frame_format.autofit_type = slides.TextAutofitType.NONE
    shape.text_frame.text_frame_format.autofit_type = slides.TextAutofitType.SHAPE
    presentation.save("output.pptx", slides.export.SaveFormat.PPTX)

My result looks fine: output.zip (20.7 KB)

Please carefully review the issue again and provide step-by-step details on how to reproduce the problem.