Apache POI Merge Multiple Decks to Single Deck

Viewed 23

I'm using Apache POI - 5.2.2 to load the decks as ByteArrayInputStream. These loaded decks to be merged to a single large deck. I'm following mentioned steps -

  1. Download the file as ByteArrayOutputStream
  2. Convert the downloaded file to InputStream
  3. Load the deck in Apache POI
   XMLSlideShow slideShow = new XMLSlideShow(stream);
  1. Iterating over each slide from the loaded deck
   slideShow.getSlides();
  1. Create a new slide in the Target Deck
   targetDeck.createSlide()
   // Another method is available but doesn't work for the layouts
   targetDeck.createSlide(srcSlide.getSlideLayout); //
  1. Tried importing content and layout from srcSlide to targetDeck Slide
        XSLFSlide newSlide = targetDeck.createSlide(srcSlide.getSlideLayout());
        // copy source layout to the new layout
        newSlide.getSlideMaster().importContent(srcSlide.getSlideMaster());
        newSlide.getSlideLayout().importContent(srcSlide.getSlideLayout());
        newSlide.importContent(srcSlide);

After all mentioned steps, when I try to output the targetDeck as stream, it doesn't retain any source layouts.

Reference

0 Answers
Related