Forcing a Fixed AutoShape Height with Text Autofit Enabled in Python

Hi team,
I have an autoshape with resize shape to fit text enabled. Right now whenever I set the shape height using aspose, it automatically readjusts itself to a particular height.
However, I want to force set height of this shape to a particular value let’s say 100 which is much larger that the current height. How can I do that ?

I am using the snippet below:

import aspose.slides as slides
import aspose.pydrawing as draw

with slides.Presentation() as presentation:
    slide = presentation.slides[0]
    auto_shape = slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 30, 30, 350, 100)

    portion = slides.Portion("lorem ipsum...")
    portion.portion_format.fill_format.solid_fill_color.color = draw.Color.black
    portion.portion_format.fill_format.fill_type = slides.FillType.SOLID
    auto_shape.text_frame.paragraphs[0].portions.add(portion)

    text_frame_format = auto_shape.text_frame.text_frame_format
    text_frame_format.autofit_type = slides.TextAutofitType.SHAPE
    auto_shape.height = 100 # does not work

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

@Prezent

To set a fixed height for an auto shape in Aspose.Slides while keeping the “Resize shape to fit text” option enabled, you need to adjust the autofit type to prevent automatic height adjustments based on the text content. Specifically, you should set the autofit type to TextAutofitType.NORMAL. Below is an example of how to implement this in your code:

import aspose.slides as slides
import aspose.pydrawing as draw

with slides.Presentation() as presentation:
    slide = presentation.slides[0]
    auto_shape = slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 30, 30, 350, 100)

    portion = slides.Portion("lorem ipsum...")
    portion.portion_format.fill_format.solid_fill_color.color = draw.Color.black
    portion.portion_format.fill_format.fill_type = slides.FillType.SOLID
    auto_shape.text_frame.paragraphs[0].portions.add(portion)

    text_frame_format = auto_shape.text_frame.text_frame_format
    text_frame_format.autofit_type = slides.TextAutofitType.NORMAL  # Set autofit type to NORMAL
    auto_shape.height = 100  # Set the desired height

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

By setting the autofit type to TextAutofitType.NORMAL, you ensure that the shape maintains the specified height without automatically adjusting based on the text content.

We want to keep the original property of the shape intact, i.e. finally it should reflect:

text_frame_format.autofit_type = slides.TextAutofitType.SHAPE

and the height should also be increased.

If you notice carefully in the microsoft powerpoint software, we can achieve this.

@Prezent,
Thank you for contacting free support. I need some time to answer your question. I will get back to you as soon as possible.

@Prezent,
Thank you for your patience. Unfortunately, I was not able to meet your requirements in PowerPoint manually. Could you please share instructions on how to accomplish this?

Thank you Andrey for your reply.

I agree for normal shapes our requirements do not meet in powerpoint.

Sincere apologies, we forgot to mention in the second reply that we have transform applied to our autoshape in powerpoint.

  1. Attaching a video herewith to demonstrate the steps in powerpoint on how to apply transform and increase shape height.

How can we achieve the same through aspose ? Currently this shape’s height does not increase if we try to increase it via aspose because of autofit = SHAPE enabled.

  1. Also, our initial query was generic in general, can we force increase the height of an autoshape with slides.TextAutofitType.SHAPE

screen recording.zip (8.1 MB)

@Prezent,
Thank you for the additional information. Unfortunately, I was unable to achieve the same results using Aspose.Slides.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESPYNET-308

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.