Create a slide and fill with text

I am using Java Api for PPT file format. I am trying and failing to create simple slide and fill with the text. Could you kindly point out what exactly am I doing wrong here?
I receive an output file with one slide, but with no text.

Presentation presentation = new Presentation();
Slide slide = presentation.addBodySlide();
presentation.getSlides().remove(presentation.getSlides().get_Item(0));

Portion formattedPortion = new Portion(CONTENT2);
formattedPortion.setFontBold(true);
formattedPortion.setText(CONTENT2);
Portion portion1 = new Portion();
portion1.setText(CONTENT1);

TextFrame textFrame = slide.getShapes().get_Item(0).addTextFrame(CONTENT1);
Paragraph paragraph1 = new Paragraph();
paragraph1.getPortions().add(portion1);
paragraph1.getPortions().add(formattedPortion);
textFrame.getParagraphs().add(paragraph1);
presentation.save(“D:\temp\test_slide_creation.ppt”, SaveFormat.Ppt);

Hi Andrey,

I have observed the requirements shared by you and like to share that you are adding the body type slide that has in fact a placeholder and for placeholders you need to use TextHolders that accommodate its text. For other normal shapes like rectangle or ellipse etc the text is managed by TextFrame. In this case you were using TextFrame for a placeholder, which was wrong. Please use the following sample code to serve the purpose. Please share, if I may help you further in this regard.

public static void TestTextFrame()
{
Presentation presentation = new Presentation();
Slide slide = presentation.addBodySlide();
presentation.getSlides().remove(presentation.getSlides().get_Item(0));

Portion formattedPortion = new Portion(“CONTENT2”);
formattedPortion.setFontBold(true);
formattedPortion.setText(“CONTENT2”);

Portion portion1 = new Portion();
portion1.setText(“CONTENT1”);


Shape shape=slide.getShapes().get_Item(0);
if( shape.getPlaceholder() !=null)
{


Paragraph paragraph1 = new Paragraph();
portion1.setFontColor(Color.RED);
formattedPortion.setFontColor(Color.BLUE);

paragraph1.getPortions().add(portion1);
paragraph1.getPortions().add(formattedPortion);

//Accessing the first placeholder in the slide and typecasting it as a text holder
//TextHolder th = (TextHolder)slide.getPlaceholders().get_Item(1);
TextHolder th = (TextHolder)shape.getPlaceholder();
th.getParagraphs().add(paragraph1);


}
presentation.save(“D:\Aspose Data\test_slide_creation.ppt”, SaveFormat.Ppt);

}

Many Thanks,