POI api Projects

POI api Project 1

Set picture as Background
Previous Home Next

In this page of the tutorials we are going try to create a slide after that change background picture of those slide. In this program we are going to create a slide. In this slide we are set the background in the slide by inserting the picture. To set the picture as background in slide we are using setPictureData(nameofpicture ) method. We are setting the pattern type of the picture. To set the pattern we are usingsetFillType(filltype) method.

Method Description

addPicture(byte[] pictureData,int format)

This methods add a picture to the workbook and the return type is int of this method. In This method two parameters are passed into this method. The first parameter is pictureData and second parameter is format .The pictureData is byte form of the picture. In this example we are using Picture.PNG as format.

setPictureData(byte[] pictureData)


package r4r;
import java.io.*;
import java.awt.Color;
import org.apache.poi.hslf.model.TextBox;
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.*;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.model.*;
public class setgbpicture {
	 public static void main(String a[])
	  SlideShow Show = new SlideShow();
	  Slide slide1 = Show.createSlide();
	  Fill fill = slide1.getBackground().getFill();
	  int d = Show.addPicture(new File
	("1.png"), Picture.PNG);
	  FileOutputStream out = new FileOutputStream
	  }catch(Exception e){}
Previous Home Next