Draw Line in PowerPoint Presentation Using Java

Ads
 

Draw Line in PowerPoint Presentation Using Java

In this example we are going to create line in PowerPoint presentation using java.

In this example we are going to create line in PowerPoint presentation using java.

Draw Line in PowerPoint Presentation Using Java

     


In this example we are going to create line in PowerPoint presentation using java.

In this example we are going to make an slide and we are inserting a line in it. To insert a line we are making a line, set line style and color.  To create an object of Line we are using Line() constructor. At last we are adding the line in slide. The setLineStyle(style) method is used to set the style of line. The setLineColor(Color color) method is used to add the color of the line.
  
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.SlideShow;
import java.io.*;
import java.awt.*;
import org.apache.poi.hslf.model.Line;
class drawLine{
  public static void main(String a[])
  {
  try
  SlideShow slideShow = new SlideShow();
  Slide slide = slideShow.createSlide();
 Line line = new Line();
 line.setAnchor(new java.awt.Rectangle
(
5050600,500));
 line.setLineColor(new Color(01280));
 line.setLineStyle(Line.LINE_DOUBLE);
 slide.addShape(line);
 FileOutputStream out = new FileOutputStream
(
"drawLine.ppt");
  slideShow.write(out);
  out.close();
  }catch(Exception e){}
  }}

The output of the program is given below:

Download this example.

Ads

Ads