How to create the color full title of the PPT slide
Previous | Home | Next |
In this page of the example we are going to create the power point slide and try to set the color to the title of that slide. for performing this we are using the getTextRuns() method.
getTextRuns():-In this program this methods get blocks of text. The getTextAsString() and getTextAsVector() are two methods. both method are used for get the block of the text. The getTextAsString() is used to get the single string with all the text in it and getTextAsVector() is used to get the vector of strings, one for each text record found in the file. We can change the text via TextRun.setText(String) or RichTextRun.setText(String). But it is not yet possible to add additional TextRuns or RichTextRuns.for performing this task we are using setFontColor(Color color) to change the color of text in this program.The org.apache.poi.hslf.usermodel.RichTextRun class is used for multiple task like change the textbox style, color, font size, font type etc. Here we are creating the object of RichText and then change the text textbox style, color, font size , font type etc.
package r4r; import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.model.Slide; import org.apache.poi.hslf.usermodel.RichTextRun; import org.apache.poi.hslf.usermodel.SlideShow; import java.io.*; import java.awt.*; import org.apache.poi.hslf.model.TextBox; public class makecolorfulltitle { public static void main(String a[]) { try { SlideShow Show = new SlideShow(); Slide slide1 = Show.createSlide(); TextBox ttl = slide1.addTitle(); ttl.setText("Rajesh Patel"); RichTextRun rtext = ttl.getTextRun(). getRichTextRuns()[0]; rtext.setFontSize(32); rtext.setFontName("Arial"); rtext.setBold(true); rtext.setItalic(true); rtext.setUnderlined(true); rtext.setFontColor(Color.BLUE); rtext.setAlignment(TextBox.AlignCenter); FileOutputStream fos = new FileOutputStream ("colorfulSlide.ppt"); Show.write(fos); fos.close(); }catch(Exception e){} } }
Previous | Home | Next |