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

Free Support Forum - aspose.com

Merged presentation has an extra empty slide


We use Java Aspose.Slides version 6.9.1 to merge several presentations into one presentation.
For most of our presentations it works well but sometimes the merged presentation contains an extra empty slide.

We did some debugging and it looks that this is because method presentation.getSlides().size() sometimes returns an incorrect value, for example for a single slide presentation it returns “2” instead of “1”.

Please see attached our source presentations, merged presentation and our Java code.

Please reproduce this issue on your side and provide this information:
1. a correct Java code to merge presentations.
2. a correct Java method to know the number of slides in a presentation.

Thanks in advance!

Hi Citbor,

I have worked with the sample code shared by you. Please try using the following sample code instead of yours. Please share if I may help you further in this regard.

public static Presentation assemblePresentation(java.util.List sourceFiles) {
final Presentation merged = new Presentation();

for (int ii = sourceFiles.size() - 1; ii >= 0; --ii) {
final String sourceFile = sourceFiles.get(ii);
appendSlides(merged, new Presentation(sourceFile));
if (merged.getSlides().getLastSlidePosition() > 1) {
final Slide empty = merged.getSlideByPosition(merged.getSlides().getLastSlidePosition());
return merged;

Many Thanks,

Hi Mudassir,

Thanks for your code, its works well for us.

And can you please confirm about method “presentation.getSlides().size()”?
As I described above, sometimes it returns an incorrect value. Please tell us a correct method which we should use to know the number of slides in a presentation.


Hi Citbor,

I like to share that the right method is the one that has been shared by me for your kind reference. If you are interested in getting the numbers of slides in slideCollection, you may need to use presentation.getSlides().getCount(). However, the correct method is the one that I have shared as the slide count may and may not be greater the total slide count visible as there can be master slides also part of slideCollection(). So. in case of PPT, I would recommend you to get slide by position and traverse them till LastSlidePostion.

Many Thanks,

So we are going to use this approach to know the number of slides in a presentation:

int size (com.aspose.slides.Presentation p) {
return p.getSlides().getLastSlidePosition() - p.getFirstSlideNumber() + 1;


Thanks for your help!

Hi Citbor,

I have discussed the issue in detail with our development team and like to share that ideally Presentation.getSlides().getCount() should give you the correct count of the slides. In your case there are total 4 slides but getCount() or size() ( both are same methods) return wrong total number of slides. I have created an issue with ID SLIDESJAVA-33822 in our issue tracking system to further investigate the issue. In my view, when you are traversing the presentation, its wise to use slide getLastSlidePosition() instead of getCount(). If you use getLastPosition() only, it will give you slide count of presentation. So, I may suggest you to please use following statement for the time being.

int size =Presentation.getSlides().getLastSlidePosition();

Many Thanks,

The issues you have found earlier (filed as SLIDESJAVA-33822) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.