Hi,
Can anyone please give the Java code to remove background image from ppt and pptx files.
This is very urgent , any help is appreciated.
I am using the following java code to insert an image:
Presentation pres = new Presentation(new FileInputStream(new File("D:/MasterBackground.ppt")));
int number = pres.getFirstSlideNumber() + pres.getSlides().getLastSlidePosition() - 1;
//Accessing a slide using its slide position
for(int i=0;i<number;i++){
Slide slide = pres.getSlides().get(i);
//Slide slide = pres.getSlideByPosition(1);
//Disable following master background settings
slide.setFollowMasterBackground(false);
//Setting the fill type of the background to picture
slide.getBackground().getFillFormat().setType(FillType.PICTURE);
//Creating a stream to hold the image file
InputStream iStream = new BufferedInputStream(new FileInputStream("D:/Winter.jpeg"));
//Creating a picture object that will be used as a slide background
Picture pic = new com.aspose.slides.Picture(pres,iStream);
//Adding the picture object to pictures collection of the presentation
//After the picture object is added, the picture is given a unique picture Id
int picId = pres.getPictures().add(pic);
//Setting the picture Id of the slide background to the Id of the picture object
slide.getBackground().getFillFormat().setPictureId(picId);
}
//Writing the presentation as a PPT file
pres.write(new FileOutputStream(new File("D:/MasterBackground.ppt")));
Regards,
Sam