We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Slides for Java ppt Slides with different masters


I’ve got a problem with ppt (97) presentations (slides for java).
Master slide information is getting lost (possibly resulting of German Umlauts in master slide names).

Presentations get uploaded (and saved slide per slide), to be combined later in a free mixture of slides from different presentation.

On some presentations we are losing information - here what I got as properties (MainMaster, masters, slides) of one:

(Main Master): name: “Leere Präsentation” slideId: 2147483829
(in a loop about ALL presentation.getMasters()):
master[0] name: “Leere Präsentation” slideId: 2147483829 slidePosition: 0

(in a loop about presentation.getSlideByPosition(presentation.getSlides().size()):

Slide name: slideId: 354 slidePosition: 1 positionIn getSlides(): 1 masterId: 2147483830
Slide name: slideId: 260 slidePosition: 2 positionIn getSlides(): 2 masterId: 2147483829
Slide name: slideId: 261 slidePosition: 3 positionIn getSlides(): 3 masterId: 2147483829
Slide name: slideId: 265 slidePosition: 4 positionIn getSlides(): 4 masterId: 2147483829
Slide name: slideId: 266 slidePosition: 5 positionIn getSlides(): 5 masterId: 2147483829
Slide name: slideId: 267 slidePosition: 6 positionIn getSlides(): 6 masterId: 2147483829
Slide name: slideId: 263 slidePosition: 7 positionIn getSlides(): 7 masterId: 2147483829
Slide name: slideId: 268 slidePosition: 8 positionIn getSlides(): 8 masterId: 2147483829
Slide name: slideId: 270 slidePosition: 9 positionIn getSlides(): 9 masterId: 2147483829
Slide name: slideId: 272 slidePosition: 10 positionIn getSlides(): 10 masterId: 2147483829
Slide name: slideId: 352 slidePosition: 11 positionIn getSlides(): 11 masterId: 2147483829
Slide name: slideId: 353 slidePosition: 12 positionIn getSlides(): 12 masterId: 2147483830
Slide name: null slideId: null slidePosition: null positionIn getSlides(): 13 masterId: null
The Presentation does contain 2 masters, one of which is found in the “presentation.getMasters()” Slides result.

The other master (listed with Slide name: null) does not have any decent attributes.

Please give me some advice how to get around this problem.


Oliver Hoch

Hi Oliver,

I have been working on the code snippet shared by you earlier but was experiencing little difficulty in understanding. Anyways, as you have now modified the query and have shared what you are actually experiencing with some slides. Theretically, when you clone a slide in PPT the respective master slide for that also gets copied. In your case it seems that possibly there may be some corrupt slide. I can offer you are a work around in which you may clone the master slide of slide to be cloned first in your target presentation. Then you got to clone the actual slide. Then you set the master slide id of the cloned slide in target presentation. In this way you will be adding few statements but will be ensuring at the same time that correct master is applied to cloned slide. For reference, I have shared the sample code that may elaborate the concept.

public static void clonePPT()

Presentation pres=new Presentation("D:\\Aspose Data\\asd.ppt");

Presentation newPres=new Presentation();

Slide SlideToBeCloned=pres.getSlides ().get(0);
Slide MasterSlide=pres.getSlideById (SlideToBeCloned.getMasterId());

//Creating TreeMap object that is used to store the temporary information
//about the masters of PPT file. No value should be added to it.
TreeMap tMap=new TreeMap();

//Cloning the selected slide at the end of another presentation file
Slide ClonedMaster=pres.cloneSlide(MasterSlide,newPres.getSlides().getLastSlidePosition() + 1,newPres,tMap);

Slide clonedSlide=pres.cloneSlide(SlideToBeCloned,newPres.getSlides().getLastSlidePosition() + 1,newPres,tMap);

clonedSlide.setMasterId(ClonedMaster.getSlideId() );

newPres.deleteUnusedMasters ();

newPres.write ("D:\\Aspose Data\\clonedNew.ppt");
catch(Exception e)
e.printStackTrace ();


Thanks and Regards,