POI api Projects

POI api Project 1

Draw Line in slide
Previous Home Next

In this page of the tutorials we are trying to draw line in PowerPoint presentation with help of java. In this program we are going to create a slide and try to draw a line in the slide. 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) methods set the style of line. The setLineColor(Color color) methods add the color of the line.


package r4r;
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;
public class drawlinetest1 {
	public static void main(String a[])
	  { SlideShow Show = new SlideShow();
	  Slide slide1 = Show.createSlide();
	 Line line1 = new Line();
	 line1.setAnchor(new java.awt.Rectangle
	(50, 50, 600,50));
	 line1.setLineColor(new Color(0, 128, 0));
	 FileOutputStream fos = new FileOutputStream("drawLine.ppt");
	  }catch(Exception e){}
Previous Home Next