importjava.io.File;importjava.io.FileOutputStream;importjava.io.IOException;importorg.apache.poi.xslf.usermodel.SlideLayout;importorg.apache.poi.xslf.usermodel.XMLSlideShow;importorg.apache.poi.xslf.usermodel.XSLFSlide;importorg.apache.poi.xslf.usermodel.XSLFSlideLayout;importorg.apache.poi.xslf.usermodel.XSLFSlideMaster;importorg.apache.poi.xslf.usermodel.XSLFTextParagraph;importorg.apache.poi.xslf.usermodel.XSLFTextRun;importorg.apache.poi.xslf.usermodel.XSLFTextShape;publicclassFormatTextPPT{publicstaticvoidmain(String args[])throwsIOException{//creating an empty presentationXMLSlideShow ppt =newXMLSlideShow();//getting the slide master objectXSLFSlideMaster slideMaster = ppt.getSlideMasters()[0];//select a layout from specified listXSLFSlideLayout slidelayout = slideMaster.getLayout(SlideLayout.TITLE_AND_CONTENT);//creating a slide with title and content layoutXSLFSlide slide = ppt.createSlide(slidelayout);//selection of title place holderXSLFTextShape body = slide.getPlaceholder(1);//clear the existing text in the slide
body.clearText();//adding new paragraphXSLFTextParagraph paragraph = body.addNewTextParagraph();//formatting line 1XSLFTextRun run1 = paragraph.addNewTextRun();
run1.setText("This is a colored line");//setting color to the text
run1.setFontColor(java.awt.Color.red);//setting font size to the text
run1.setFontSize(24);//moving to the next line
paragraph.addLineBreak();//formatting line 2XSLFTextRun run2 = paragraph.addNewTextRun();
run2.setText("This is a bold line");
run2.setFontColor(java.awt.Color.CYAN);//making the text bold
run2.setBold(true);
paragraph.addLineBreak();//formatting line 3XSLFTextRun run3 = paragraph.addNewTextRun();
run3.setText(" This is a striked line");
run3.setFontSize(12);//making the text italic
run3.setItalic(true);//strike through the text
run3.setStrikethrough(true);
paragraph.addLineBreak();//formatting line 4XSLFTextRun run4 = paragraph.addNewTextRun();
run4.setText(" This an underlined line");
run4.setUnderline(true);//underlining the text
paragraph.addLineBreak();//creating a file objectFile file =newFile("C:/poippt/FormatedText.pptx");FileOutputStream out =newFileOutputStream(file);//saving the changes to a file
ppt.write(out);
out.close();System.out.println("PPT created");}}