Menu

Add Background to Slides

Shoaib

Apache POI SL

SlideMaster master = ppt.getSlidesMasters()[0];

Fill fill = master.getBackground().getFill();
int idx = ppt.addPicture(new File("data/background.jpg"), Picture.JPEG);
fill.setFillType(Fill.FILL_PICTURE);
fill.setPictureData(idx);

Aspose.Slides

//Instantiate the Presentation class that represents the presentation file
Presentation pres = new Presentation();

//Set the background with Image
pres.getSlides().get_Item(0).getBackground().setType (BackgroundType.OwnBackground);
pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType ( FillType.Picture);
pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().setPictureFillMode( PictureFillMode.Stretch);

//Set the picture
IPPImage imgx =null;
imgx = pres.getImages().addImage(new FileInputStream(new File("data/background.jpg")));

//Image imgx = pres.getImages().addImage(image);
//Add image to presentation's images collection

pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().getPicture().setImage (imgx);

Download Source Code


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.