POI api Projects

POI api Project 1

Change Background of Slide
Previous Home Next

In this page of the tutorials we are trying to create a slide then change background of the slide. In this example we creates an object of the shape. In this object of the shape we are assigning rectangle shape and set the size and position.

Initial values for x and y axis are 0.The height and width are 400 and 400 respectively.Then create an object of Shape and set values, fill type, background color and foreground color of the slide.

Then finally add into slide. We are using setFillType(Fill.FILL_SHADE) method to set fill type, setBackgroundColor(Color.blue) method to set background color and setForegroundColor(Color.green) method to set the text color.


package r4r;
import org.apache.poi.common.usermodel.Fill;
import org.apache.poi.hslf.model.AutoShape;
import org.apache.poi.hslf.model.ShapeTypes;
import org.apache.poi.hslf.model.Slide;
import java.io.*;
import java.awt.Color;
import java.awt.Shape;
public class changebgofslide {
	public static void main(String a[])
	  SlideShow Show = new SlideShow();
	  Slide slide1 = Show.createSlide();
	  Shape shape1 = (Shape) new AutoShape(ShapeTypes.Rectangle);
	  ((org.apache.poi.hslf.model.Shape) shape1).setAnchor(new java.awt.Rectangle(0, 0, 400, 400));
	  org.apache.poi.hslf.model.Fill fill = ((org.apache.poi.hslf.model.Shape) shape1).getFill();
	  slide1.addShape((org.apache.poi.hslf.model.Shape) shape1);
	  FileOutputStream out = new FileOutputStream
	  }catch(Exception e){}
Previous Home Next