Sign In  Sign Up Live-Chat

Adding Title with TextFrame

Last post 06-06-2008, 1:09 PM by jfallon_emc. 2 replies.
Sort Posts: Previous Next
  •  04-17-2008, 1:41 PM 122846

    Adding Title with TextFrame

    Attachment: Present (inaccessible)

    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; 

     

    pres.Write("c:\\outTitle.ppt");


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  06-06-2008, 12:47 AM 130295 in reply to 122846

    Re: Adding Title with TextFrame

    Here is the same code as above in JAVA.

    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);

    rect.getLineFormat().setShowLines(false);

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

    //Center align it

    tf.getParagraphs().get(0).setAlignment(TextAlignment.CENTER);

    //Set formatting

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

    //To set font height

    port.setFontHeight((short)44);

    //To set font

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

    newFont.setFontName("Comic Sans MS");

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

    port.setFontIndex(newFontIdx);

    //To set color

    port.setFontColor(Color.BLUE);

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


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  06-06-2008, 1:09 PM 130399 in reply to 130295

    Re: Adding Title with TextFrame

    O, I'm actually using VB .Net, but c# reads close enough so the example works for me :)
     
View as RSS news feed in XML