How to split a pptx file?

Hi,

I would like to split a pptx file that contains 50 slides into 50 pptx with one slide.

Thanks

Hello,

It is possible to split PPTX presentation using slide cloning. The example of it can be found at this link.

http://www.aspose.com/community/files/51/file-format-components/aspose.slides-for-.net-and-java/entry140061.aspx

I will also provide you a code example as soon as possible.

thanks, I’m waiting for your code example.

I'm trying the following code :

Powerpoint.Pptx.PresentationEx _doc = new Powerpoint.Pptx.PresentationEx(new MemoryStream(bytes));

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

{

Powerpoint.Pptx.SlideEx slide = _doc.Slides[i];

Powerpoint.Pptx.PresentationEx _newdoc = new Powerpoint.Pptx.PresentationEx(new MemoryStream());

_newdoc.Slides.AddClone(slide);

_newdoc.Write(dir + @"\" + Path.GetFileNameWithoutExtension(file) + "_" + (i + 1) + Path.GetExtension(file));

}

but, I get the error :

"central directory not found, probably not a zip file" on the line : Powerpoint.Pptx.PresentationEx _newdoc = new Powerpoint.Pptx.PresentationEx(new MemoryStream());

How can I create an empty PPTX file ?

Please see the code & solution in this thread

How to split the PPTX presentation into individual slides?

Now I get the following error :

"Clonning slide from other presentation isn't supported yet."

Powerpoint2007.PresentationEx srcPres = new Powerpoint2007.PresentationEx(new MemoryStream(bytes));

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

{

Powerpoint2007.SlideEx slide = srcPres.Slides[i];

Powerpoint2007.PresentationEx dstPres = new Powerpoint2007.PresentationEx(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Empty.pptx"));

dstPres.Slides.AddClone(slide);

dstPres.Slides.RemoveAt(0);

dstPres.Write(dir + @"\" + Path.GetFileNameWithoutExtension(file) + "_" + (i + 1) + Path.GetExtension(file));

}

up

No way ?

The AddClone(SlideEx slide) can’t clone a slide from other presentation, but other overloads (with additional parameters) can.
Please, see example.

Hi

I'm using the last version of Aspose.Slides and I have no overload on the AddClone method ...

Regards

There are three AddClone methods in SlidesEx class:

public int AddClone(SlideEx);

- clones slide within the presentation only. This method can’t clone slide from other presentation because there no way to determine, which layout should be linked to the cloned slide.

public int AddClone(SlideEx,LayoutSlideEx);
- clones any slide (including slides from other presentation), linking slide to specified layout
public int AddClone(SlideEx,MasterSlideEx);
- clones any slide (including slides from other presentation), selecting layot automatically fom specified master.

In your case best is the third variant. You should clone slide's master (all layouts will be cloned automatically) and then clone slide itself, specifying clone of slide's master as the second parameter.

Sorry, I tought that I used the last version of Aspose.Slides but that was an older one (2.8.5.0) which doesn't have overload on AddClone method.

That works great now, thanks for the help.