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

Free Support Forum - aspose.com

Adding new TextBox shape to slide

Is it possible to add a Title TextBox shape to a blank slide using aspose.java?

Requirement is: my initial slide is blank. there is no place holders for title.
I want to add one / more text holders dynamically, where I want to put rich text.



For some basic concepts regarding Placeholders, TextHolders, Shapes etc, please visit this topic from online Aspose.Slides for Java documentation. To add a slide with text holders, here is the sample code:

Presentation pres=new Presentation();

Slide sld= pres.addTitleSlide();

TextHolder thld=(TextHolder)sld.getPlaceholders().get(0);

TextHolder thld1=(TextHolder)sld.getPlaceholders().get(1);

thld.setText("Click to add title");

thld1.setText("Click to add subtitlle");


My requirement is as follows:-
I am creating new ppt from an existing ppt file, which has predefined styles, logos etc.

Now, i am creating new slide using.

Slide sld = pres.cloneSlide(firstSld, 2);
Now I want to add a rich text container shape. Is it possible in aspose?

If I use the following code, I lose predefined logo(embedded picture) available in my presentation. pres.addBodySlide()

So the question is is it possible to add rich text shape dynamically through code?


There are two ways to do it:

Approach 1)

a) Clone the existing slide.

b) Create a Rectangle shape to the cloned slide and add a TextFrame to the cloned slide. You can apply text styles to the text carried by TextFrame using Paragraph and Portion objects associated with a TextFrame.

Approach 2)

a) Add your predefined logo in the master slide.

b) Use Presentation.addBodySlide that will inhert the same style as defined by master slide and use the code i have provided in my previous post.

My recommendation is Approach 2. You can provide me the source presentation so that i can provide a sample code for both approaches.