Wildpig16
Wildpig16

Reputation: 1

Split pptx Slideshow with Apache POI

I want to split a pptx slideshow into several slideshows each containing only one slide by using the Apache POI Java library.

Creating a new XMLSlideSheet and adding a slide as described in several places(e.g. https://www.tutorialspoint.com/apache_poi_ppt/apache_poi_ppt_merging.htm) does not work for me, as some of the layout is not imported correctly: Fonts are changed, positioning of text is changed, etc.

  1. Question: How can I import not only the content and the master layout but also themes when importing slides into a new XMLSlideShow?

One thing that does work is importing the pptx file one time for each slide and then iterating over all slides, deleting all but one single slide. However, the drawback of this approach so far is, that the file size of the resulting pptx-one-slide-file is as large as the big input slidedeck with x slides. Thus, deleting a slide via XMLSlideShow -> removeSlide(slideID) seems to not remove all images, relations, etc. from the slideshow.

  1. Question: How can I delete all parts from a XMLSlideshow that is not needed anymore after removing all but one slide?

Thank you for you help!

Upvotes: 0

Views: 564

Answers (1)

bmateusz
bmateusz

Reputation: 237

  1. Start by opening the full pptx and removing slides from it one-by-one. That way you preserve master slides and other properties.

  2. You can try a cycle on the shapes of the slide and remove them, something like this:

for (shape: slide.getShapes()) { slide.removeShape(shape) }

Upvotes: 0

Related Questions