Using TextHolders

In an earlier post alcrus said I could not construct a text holder.

Reference: http://www.aspose.com/Community/Forums/45590/ShowPost.aspx

But I constructed a textholder!!! Why do I get a TextHolder when I do slide.addBodySlide(); ?

Presentation outP = new Presentation();
Slide slide1 = outP.addBodySlide();
Placeholder plh = slide1.getPlaceholders().get(0);
System.out.println(plh.toString());

// Prints … com.aspose.slides.TextHolder@e91f5d

Looks like a textholder to me … So what’s the deal??

And when I open in powerpoint, there’s an empty bullet on the slide I created.

So now I want to populate that bullet. I just want to programatically create a slide with bullets. As naturally as I did in raw powerpoint. And based on an earlier post, I was advised to place and format rectangles when I don’t need to. Please tell me how this is supposed to be done.

If someone would answer this post, it would relieve a significant amount of frustration !!

http://www.aspose.com/Community/Forums/45525/ShowPost.aspx

You created slide with TextHolder. That is possible of course.
Create new TextHolder on empty slide and create slide with TextHolder are different things.

Now about examples how to add text with bullets. Did you read Programmer’s Guide in the Wiki?
Aspose Documentation
Also almost every demo has examples how to change text on TextHolder.

Placeholders pholders = pres.getSlideByPosition(1).getPlaceholders();
TextHolder th = (TextHolder) pholders.get(0);
th.getParagraphs().get(0).getPortions().get(0).setText("Hello World ");

To add one more Paragraph with bullet you should write:

Paragraph para = new Paragraph(th.getParagraphs().get(0)); // Clone existing paragraph
th.getParagraphs().add(para); // add it to the collection
para.getPortions().get(0).setText(“One more paragraph”); // overwrite text

Can you explain this? TextHolder does not have a method getParagraphs(). I want to find out how to add more bullets to my paragraph. I looked at “Wiki” link and it seems to have the same thing as the “API” link. I could not find any examples on how to add Textholders or bullet points. Do I have to add a rectangle shape and then add a TextFrame?

Slide bodySlide = pres.AddBodySlide();
Paragraph para = ((TextHolder)bodySlide.Placeholders[0]).Paragraphs[0];
para.Alignment = TextAlignment.Center;
para.Text = “This is a Body Slide”;

TextHolder th = (TextHolder)bodySlide.Placeholders[0];
para = ((TextHolder)bodySlide.Placeholders[1]).Paragraphs[0];
para.Alignment = TextAlignment.Left;
para.HasBullet = 1;
para.BulletColor = Color.Blue;
para.BulletHeight = 125; // bullet height
para.Portions[0].FontUnderline = true;
para.Text = “Item 1”;

Thanks.

Dear lajolla,

Thanks for considering Aspose.Slides.

There are two versions of Aspose.Slides, one is for .NET and one is for JAVA. The code you pasted is for .NET version.

The .NET version has TextHolder.Pargraphs property, while JAVA version has TextHolder.getParagraphs() property. JAVA version have all the properties of .NET version but that start with set and get prefixes.

I see. I could not tell your solution was for Java API. I followed your methodolgy and I got it working now. Thanks.