How to Add new TextBoxes on new Slide

Last post 04-27-2009, 9:08 PM by mshakeel.faiz. 5 replies.
Sort Posts: Previous Next
  •  07-30-2007, 2:28 PM 88570

    How to Add new TextBoxes on new Slide

    Received : 2007/07/30 14:28:36
    Message : I'm a perspective buyer and was wondering how your able to put a new textbox onto a new slide. I've created a new slide and the variable is mySlide. I'm not sure how to add a new object onto the slide.


    This message was posted using Aspose.Live 2 Forum
     
  •  07-30-2007, 3:06 PM 88576 in reply to 88570

    Re: How to Add new TextBoxes on new Slide

    Attachment: Present (inaccessible)

    Dear Crafte,

     

    Thank you for considering Aspose.Slides.

     

    Textboxes are called TextFrames in Aspose.Slides. Below is the code that add a textframe in presentation and write it on disk.

     

     

    I have attached the presentation generated by this code for you to view alongwith the code.

     

    void AddSampleTextFrame()

    {

    //Create presentation

    Presentation srcPres = new Presentation();

    //Get first Slide, first slide is added automatically

    Slide firstSlide = srcPres.GetSlideByPosition(1);

    //Add Rectangle inside the first slide

    //This rectangle will contain the textframe inside it

    Aspose.Slides.Rectangle rect = firstSlide.Shapes.AddRectangle(300, 1000, 5200, 1);

    //Make its line invisble

    rect.LineFormat.ShowLines = false;

    //Now add a text frame inside the rectangle with some sample text

    rect.AddTextFrame("This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.");

    TextFrame tf = rect.TextFrame;

    //Bold the text

    tf.Paragraphs[0].Portions[0].FontBold = true;

    //Set its wrap text property true, so it wraps text automatically

    tf.WrapText = true;

    //Set this propert true, so textframe can chage its shape automatically

    tf.FitShapeToText = true;

    //write the presentation

    srcPres.Write("c:\\outSampleTextFrame.ppt");

    }

     

    If you are new to Aspose.Slides, then please read Programmer’s Guide section on Aspose.Slides Wiki from the link below

    http://www.aspose.com/Downloads/Aspose.Slides/Default.aspx


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
  •  07-30-2007, 3:55 PM 88593 in reply to 88576

    Re: How to Add new TextBoxes on new Slide

    Hi,

        Thanks for the reply.  Is the code you wrote up top in Java?  Thats what I'm currently using and I'm getting a few errors.  I see the logic you used.   I've tried to use Apache POI HSLF and the main reason I'm looking to buy another software is their lack of ability to format certain portions of the "TextFrame" .  I was wondering if Apose can do that?  I've posted an example below.  Thanks

    --------

    This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text.This is sample text

     

    ---------------

    I need to be able to add bullets to certain sections of the paragraphs as well as bold, underline, and italics text.  Does Aspose have the functionality built in?   I'm looking to trasnfer HTML into powerpoint slides.  Thanks again for the help.  I hope Aspose is the suite I'm looking for.

     

     
  •  07-30-2007, 11:02 PM 88610 in reply to 88593

    Re: How to Add new TextBoxes on new Slide

    Dear Crafte,

     

    The code is actually in C#, but since the both versions of Aspose.Slides i.e .NET and JAVA support almost same APIs, the code can easily be converted into the JAVA.

     

    The only difference is that read/write properties in JAVA have prefixes get and set.

     

    For example, in C# you can change the text of the TextFrame using this code

    Tf.Text=”Some text”;

     

    But the same thing in JAVA would be like this

    Tf.setText(“Some Text”);

     

    To see online reference of JAVA APIs for Aspose.Slides for Java, follow this link

    http://www.aspose.com/Products/Aspose.Slides/JavaDoc/

     

    And for .NET follow this link

    http://www.aspose.com/Products/Aspose.Slides/Api/

     

    Yes, Aspose.Slides provide the ability to format portions of the text inside the textframe. Each textframe contains a collection of paragraph objects each of which contains a collection of portion objects.

     

    For example, if you want to set the second portion of the first paragraph of textframe to bold font, you will write code like this

     

    tf.Paragraphs[0].Portions[0]..FontBold=true (C#)

     

    tf.getParagraphs().get(0).getPortions(1).setFontBold(true) (JAVA)

     

    Please also see Working with Text section in Programer’s Guide on Aspose.Slides Wiki. It includes code examples in C#, VB.NET, JAVA and PHP

    http://www.aspose.com/Wiki/Default.aspx/Aspose.Slides/

     

    You can set the font bold, italic, underline, add bullets. However you will have to write code yourself to covert HTML to PowerPoint.

     

     


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
  •  04-27-2009, 1:02 AM 176743 in reply to 88610

    Re: How to Add new TextBoxes on new Slide

    Attachment: Present (inaccessible)
    I have a similar problem. I have to use the formatting as shown in the attached image. Does Aspose NOW support the html in the textframe? Or we still need to add code for converting HTML to render correctly in the textframe?
     
  •  04-27-2009, 9:08 PM 176935 in reply to 176743

    Re: How to Add new TextBoxes on new Slide

    Aspose.Slides cannot import html formatting, so you will have to write such a code yourself.


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML