Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Poi Make Colorful Title of PowerPoint Slide Using Java

Related Tutorials


 
 

Share on Google+Share on Google+

Make Colorful Title of PowerPoint Slide Using Java

Advertisement
In this example we are going to create a PowerPoint slide and set color full title.

Make Colorful Title of PowerPoint Slide Using Java

     

<
In this example we are going to create a PowerPoint slide and set color full title.

The methods used in this example:
getTextRuns():
This method is used to get blocks of text. The getTextAsString() and getTextAsVector() are two methods which are used to get the text back. The getTextAsString() returns a single string with all the text in it and getTextAsVector() returns a 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.

In this example we are using setFontColor(Color color) to change the color of text. The org.apache.poi.hslf.usermodel.RichTextRun class is used to 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.
The code of the program is given below:
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;
class colorfulSlideTitle
{  public static void main(String a[])
  {
  try
  {  SlideShow slideShow = new SlideShow();
  Slide slide = slideShow.createSlide();
  TextBox title = slide.addTitle();
  title.setText("Rajesh Kumar");
    RichTextRun richtextrun = title.getTextRun().
getRichTextRuns
()[0];
  richtextrun.setFontSize(32);
    richtextrun.setFontName("Arial");
    richtextrun.setBold(true);
    richtextrun.setItalic(true);
    richtextrun.setUnderlined(true);
    richtextrun.setFontColor(Color.red);
    richtextrun.setAlignment(TextBox.AlignRight); 
  FileOutputStream out = new FileOutputStream
(
"colorfulSlideTitle.ppt");
  slideShow.write(out);
  out.close();
  }catch(Exception e){}
  }}

The output of the program is given below:

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 14, 2008

Related Tutorials

Discuss: Make Colorful Title of PowerPoint Slide Using Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com