Hi,
In fact, you are using a Text Box in your template which does not resize through TextFrame.FitShapeToText property. There are two ways to achieve the desired results.
1) Update your template by converting Text Box to Rectangle. After that, add a text frame to the rectangle and set text frame properties through Aspose.
2) With the same template, create a rectangle having similar formatting as that of textbox. An example is as follows:
Presentation pres = new Presentation("d:\\ppt\\ze\\txtSpace_2.ppt");
Slide sld = pres.GetSlideByPosition(1);
int intX = 0;
int intY = 0;
int intHt = 0;
int intWt = 0;
Color bkcol = new Color();
Color frcol = new Color();
Color lncol = new Color();
foreach (Aspose.Slides.Shape shp in sld.Shapes)
{
if (shp is Aspose.Slides.Rectangle)
{
Aspose.Slides.Rectangle rect = (Aspose.Slides.Rectangle)shp;
intX = rect.X;
intY = rect.Y;
intHt = rect.Height;
intWt = rect.Width;
bkcol = rect.FillFormat.BackColor;
frcol = rect.FillFormat.ForeColor;
lncol=rect.LineFormat.ForeColor;
rect.Width = 0;
}
}
Aspose.Slides.Rectangle rect1 = sld.Shapes.AddRectangle(intX,intY,intWt,intHt);
rect1.FillFormat.Type = FillType.Solid;
rect1.FillFormat.BackColor = bkcol;
rect1.FillFormat.ForeColor = frcol;
rect1.LineFormat.ForeColor = lncol;
TextFrame tf = rect1.AddTextFrame("Somewhat_short_text");
Paragraph para2 = new Paragraph();
Portion port2 = new Portion();
tf.Paragraphs.Add(para2);
tf.Paragraphs[1].Portions.Add(port2);
tf.Paragraphs[1].Portions[0].Text = "Text_that_causes_the_new_line.";
tf.FitShapeToText = true;
pres.Write("d:\\ppt\\ze\\txtSpc_2.ppt");