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

Free Support Forum - aspose.com

How to split the PPTX presentation into individual slides?

The sample code below splits the source presentation Source.pptx into its individual slides. To achieve it we make use of another intermediate presentation Empty.pptx with single blank slide.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

All of the source and output presentations have been attached for your reference

For a short note, first clone the master slide of the source slide into destination presentation and then clone source slide itself.



string pathSourcePres = @"C:\Test\Source.pptx";

string pathEmptyPres = @"C:\Test\Empty.pptx";

//Source presentation

PresentationEx srcPres = new PresentationEx(pathSourcePres);

//Iterate all the slides in source presentation

//and clone them into destination presentation

for (int i = 0; i < srcPres.Slides.Count; i++)


//Access source slide

SlideEx srcSld = srcPres.Slides[i];

//Access source slide master

MasterSlideEx srcSldMaster = srcSld.LayoutSlide.MasterSlide;

//Create a destination presentation where source slide

//will be cloned

//Note: destination presentation has already one blank slide

//we will remove it at the end

PresentationEx dstPres = new PresentationEx(pathEmptyPres);

//First clone source slide master into destination presentation

int index=dstPres.Masters.AddClone(srcSldMaster);

//Then access the destination slide master

MasterSlideEx dstSldMaster = dstPres.Masters[index];

//Now, clone source slide with destination slide master

dstPres.Slides.AddClone(srcSld, dstSldMaster);

//Remove the unwanted blank slide in destination presentation


//Write the destination presentation onto disk

int slideNum = i + 1;

dstPres.Write("c:\\Test\\slide" + slideNum + ".pptx");


I have downloaded the java version and tried this code below. The problem is each “single slide” contains the entire deck. What am I doing wrong?

import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import com.aspose.slides.*;

public class TestAspose
public static void main(String[] args) throws IOException
String in = “C:/temp/ppt/in.pptx”;
String outdir = “C:/temp/ppt/out/”;
LoadOptions l = new LoadOptions();

l.setLoadFormat( LoadFormat.Auto);
PresentationEx pres = new PresentationEx( in, l);

int i = 0;
for( Iterator slideIter = pres.getSlides().iterator(); slideIter.hasNext():wink:
SlideEx s = slideIter.next();
MasterSlideEx sm = s.getLayoutSlide().getMasterSlide();
PresentationEx p = new PresentationEx();
int smid = p.getMasters().addClone( sm);
MasterSlideEx smd = p.getMasters().get_Item( smid);
p.getSlides().addClone( s, smd);
p.getSlides().removeAt( 0);
p.write( new File( outdir + i++ + “.pptx”).getAbsolutePath());

Update: the feedback below helped my isolate my issue, I corrected the code above. Thanks.

Hi Chris,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please share your template and generated presentation file with us to reproduce the issue. We will check it and get back to you.

Thanks & Regards,

Hi Chris,

Thanks for your interest in Aspose.Slides.

I have observed the sample code shared along with your requirements. If your requirement is that there should be single slide presentation generated for every slide then following statement is false.

PresentationEx p = new PresentationEx( tmp);

You may please use the following statement on your end to obtain a single slide presentation.

PresentationEx p = new PresentationEx( );

Many Thanks,

Thanks for the tip, Mudassir. I updated the code above and it looks to be working now. Thanks.