We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextFrameFromat.AutofitType value is not applied to text automatically when presentation is opened in PowerPoint

Hi.


We are using aspose.slides component to generate presentations from code. We want to use autofit options of a TextFrame. According to product’s documentation we can achive this by setting value of the TextFrame.TextFrameFormat.AutofitType property.

But it seems that it’s not enough. Result presentation contains correct value of the Autofit property but font size/shape size are not adjusted. If user changes shape size automatically font size will be recalculated to fit the shape.

Is there any way to adjust font size/shape size according to value of the autofit property when we building presentation? Or maybe it’s possible to force PowerPoint application to recalculate shape/text sizes when it opens our presentation?

Here’s code sample:
	var presentation = new Presentation("./source.pptx");
<span style="color:blue;">var</span> targetShape = (<span style="color:#2b91af;">IAutoShape</span>)presentation.Slides[0].Shapes.First(x => x.AlternativeText == <span style="color:#a31515;">"target"</span>);

<span style="color:blue;">var</span> textFrame = targetShape.TextFrame ?? targetShape.AddTextFrame(<span style="color:#a31515;">""</span>);

textFrame.TextFrameFormat.AutofitType = <span style="color:#2b91af;">TextAutofitType</span>.Normal;
textFrame.Text = <span style="color:#a31515;">"Very very long text"</span>;

presentation.Save(<span style="color:#a31515;">"./result.pptx"</span>, <span style="color:#2b91af;">SaveFormat</span>.Pptx);
		
<span style="color:blue;">var</span> process = <span style="color:#2b91af;">Process</span>.Start(<span style="color:#2b91af;">Path</span>.GetFullPath(<span style="color:#a31515;">"./result.pptx"</span>));</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Also I've attached template and result files.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Thanks in advance!</pre></div>

Hi Pavel,


Thank you for your interest in Aspose.Slides.

I have observed your comments and files. I would like to request you to please visit this documentation link for your kind reference. You need to set the TextAutofitType property as in the documentation article which I have shared with you.

Please let us know if the issue persists. We will be happy to assist you further.

Best Regards,

Thank you for your reply.


Documentation link that you’ve provided solves only part of the our problem. TextAutofitType.Shape works as expected but we also interested in TextAutofitType.Normal mode (this value is set in provided sample). Is this autofit mode supported?

Hi Pavel,


I have observed your comments and like to share with you that TextAutofitType.Normal is supported by Aspose.Slides for .NET but it would not fit the text into the shape. The text would be fit into the shape only if the TextAutofitType is set to Shape.

I hope this will clarify the concept. Please share if I may help you further in this regard.

Best Regards,