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)
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.
@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?
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.
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.
Also, our initial query was generic in general, can we force increase the height of an autoshape with slides.TextAutofitType.SHAPE
@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.