I want to split a powerpoint file, so that there is 1 file per slide. I want to do this for several files
Also I want to then take some of these files and create a new presentation
Can I do this?
I want to split a powerpoint file, so that there is 1 file per slide. I want to do this for several files
Also I want to then take some of these files and create a new presentation
Can I do this?
Sure, you can. All these things can be done through creating empty presentation and cloning slides.
This short example will save all slides as separate ppt files:
for (int i = 1; i <= srcPres.Slides.LastSlidePosition; i++)
{
// Create new presentation and clone slide
Presentation newPres = new Presentation();
srcPres.CloneSlide(srcPres.GetSlideByPosition(i), 2, newPres, new SortedList());
// Delete first empty slide
newPres.Slides.Remove(newPres.GetSlideByPosition(1));
// Save created presentation with one slide to a new file
newPres.Write(“slide” + i + “.ppt”);
}
The above code written by Alexey is in C#, below is the equivalent code in Java.
JAVA
//Read the source presentation
Presentation srcPres = new Presentation(new FileInputStream("c:\\source.ppt"));
int lastSlidePosition = srcPres.getSlides().getLastSlidePosition();
for (int i = 1; i <= lastSlidePosition; i++) {
// Create new presentation and clone slide
Presentation newPres = new Presentation();
//Make slide size equal in both presentation
newPres.setSlideSize(srcPres.getSlideSize());
// Clone the slide from source into new presentation
Slide srcSld = srcPres.getSlideByPosition(i);
srcPres.cloneSlide(srcSld, 2, newPres, new TreeMap());
// Delete first empty slide
newPres.getSlides().remove(newPres.getSlideByPosition(1));
// Save created presentation with one slide to a new file
newPres.write(new FileOutputStream("c:\\slide" + i + ".ppt"));
}
Thanks Shakeel Faiz. I was looking for the same code. it really works fine for me. It helped me a lot
Thanks,
Mohans