Free Support Forum -

Convert PowerPoint to a set of Images

I’m trying to convert an existing powerpoint to a new powerpoint that contains only a image of the original powerpoint. I read that as of now you dont have a way to add a new slide to a powerpoint (is the enterprise version available yet?)
I would be ok with replacing the current slide with an image or adding an image to a new powerpoint and slide - Below is what I have - Thanks for your help.

Aspose.PowerPoint.Presentation pres1 = new Presentation( templatePath );
Aspose.PowerPoint.Presentation pres2 = new Presentation( Server.MapPath(“UploadDir”) +"\testReadonly.ppt" );
System.Drawing.Imaging.EncoderParameters encoderParams = new System.Drawing.Imaging.EncoderParameters();
System.Drawing.Imaging.EncoderParameter encoderParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality,“0”);
encoderParams.Param[0] = encoderParam;
SortedList temp = new SortedList();
int picid=0;
for (int i = 1; i < pres1.Slides.Count; i++)
Slide slide = pres2.GetSlideByPosition(i);
if (slide != null)
pres2.CloneSlide(slide, pres1.Slides.LastSlidePosition + 1, pres1, temp);
string fname = String.FormatServer.MapPath(“UploadDir”) +“thumb”+ i +".png" );
pres1.SlidesIdea.GetThumbnail(1, 1).Save(fname);
picid = pres2.Pictures.Add(new Picture(pres1, fname));
//pres.CloneSlide(pres1.Slides[0],pres1.Slides.LastSlidePosition + 1,pres1,new SortedList());
pres1.SlidesIdea.Background.PictureId =picid;
pres2.Write(Server.MapPath(“UploadDir”) + “testReadonly.ppt”);

Dear Youlead514,

Anything wrong with this code?

Probably first enterprise edition with possibility to add new slides (only this feature yet)
will be available on these weekends.

I still need to get this working - I'm able to create an image of an existing powerpoint slide but I need to know how to insert this into a new powerpoint. for 1 to n pages, Thanks

Dear youlead514,

Please try something like this.
I’m writing it directly in the forum and didn’t test this code.

// Source presentation
Presentation pres1 = …;

// Target presentation. Must be a presentation with one slide.
Presentation pres2 = …;

int lastPos = pres1.Slides.LastSlidePosition;
for (int i = 1; i <= lastPos; i++)
Slide sl = pres1.GetSlideByPosition(i);
if (sl != null)
Image img = sl.GetThumbnail(1.0, 1.0);
Slide sl2 = pres2.AddEmptySlide();
int picid = pres2.Pictures.Add(new Picture(pres, img));
sl2.Shapes.AddPictureFrame(picid, 0, 0, pres2.SlideSize.Width, pres2.SlideSize.Height);