How to draw line in slide using POI
Previous | Home | Next |
In this page of the example 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.
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[]) { try { 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)); line1.setLineStyle(Line.LINE_TRIPLE); slide1.addShape(line1); FileOutputStream fos = new FileOutputStream("drawLine.ppt"); Show.write(fos); fos.close(); }catch(Exception e){} } }
Previous | Home | Next |