Adding Title with TextFrame

You can use TextFrame to add text and set its formatting, fonts etc.

Below is the C# code to do so, please also see the output presentation attached. It also gives you idea, how to use Aspose.Slides to change formatting of text.

C# Code

Presentation pres = new Presentation();
Slide sld = pres.GetSlideByPosition(1);

//Adding Title with textframe
Aspose.Slides.Rectangle rect = sld.Shapes.AddRectangle(432, 384, 4896, 720);
rect.LineFormat.ShowLines = false;
TextFrame tf = rect.AddTextFrame("Your Title Text");

//Center align it
tf.Paragraphs[0].Alignment = TextAlignment.Center;

//Set formatting
Portion port = tf.Paragraphs[0].Portions[0];

//To set font height
port.FontHeight = 44;

//To set font
FontEntity newFont = new FontEntity(pres, pres.Fonts[0]);
newFont.FontName = "Comic Sans MS";
int newFontIdx = pres.Fonts.Add(newFont);
port.FontIndex = newFontIdx;

//To set color
port.FontColor = Color.BlueViolet;


Here is the same code as above in JAVA.



Presentation pres = new Presentation();

Slide sld = pres.getSlideByPosition(1);

//Adding Title with textframe

com.aspose.slides.Rectangle rect = sld.getShapes().addRectangle(432, 384, 4896, 720);


TextFrame tf = rect.addTextFrame("Your Title Text");

//Center align it


//Set formatting

Portion port = tf.getParagraphs().get(0).getPortions().get(0);

//To set font height


//To set font

FontEntity newFont = new FontEntity(pres, pres.getFonts().get(0));

newFont.setFontName("Comic Sans MS");

int newFontIdx = pres.getFonts().add(newFont);


//To set color


pres.write(new FileOutputStream("c:\\outTitle.ppt"));

O, I’m actually using VB .Net, but c# reads close enough so the example works for me :slight_smile: