Add Slides to Presentation using Apache POI and Aspose.Slides
Contents
[
Hide
]
Aspose.Slides - Add Slides to Presentation
Aspose.Slides for Java allows developers to add empty slides to their presentation. To add an empty slide in the presentation, please follow the steps below:
- Create an instance of Presentation class
- Instantiate ISlideCollection class by setting a reference to the Slides (collection of content Slide objects) property exposed by the Presentation object.
- Add an empty slide to the presentation at the end of the content slides collection by calling the AddEmptySlide method exposed by ISlideCollection object
- Do some work with the newly added empty slide
- Finally, write the presentation file using the Presentation object
//Instantiate a PresentationEx object that represents a PPTX file
Presentation pres = new Presentation("presentation.pptx");
//Add Slide
ISlide slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
Apache POI SL - HSLF XSLF - Add Slides to Presentation
New slide can be added to presentation by SlideShow.createSlide method using Apache POI SL - HSLF and XSLF.
//create a new empty slide show
SlideShow ppt = new SlideShow();
//add first slide
Slide s1 = ppt.createSlide();
//add second slide
Slide s2 = ppt.createSlide();
Download Running Code
Download Sample Code
For more details, visit Adding Slides to Presentation.