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

Free Support Forum - aspose.com

Generating a thumbnail for PPTX slides throws "Parameter is not valid" error

I am trying to convert an entire PPTX deck into a set of thumbnail images. This works fine for PPT slides (although the code is slightly different - see at the bottom of this post), but I keep getting a cryptic error when trying to convert the PPTX slides. I googled this online, but no one really seems to have an answer. Is this a bug in the ASPOSE.SLIDES object?

My code is below:

PresentationEx presEx = new PresentationEx(sPath + Path.DirectorySeparatorChar + filename);

for (int i = 1; i < presEx.Slides.Count; i++)

{

//Accessing a slide using its slide position

SlideEx oSlideEx = presEx.GetSlideById(presEx.Slides[i].SlideId);

//Getting the thumbnail image of the slide of a specified size

Bitmap image = oSlideEx.GetThumbnail(1021, 781); //new Size(290, 230)

//Saving the thumbnail image in jpeg format

//image.Save(slideImagePath + "\\thumbnail" + i.ToString("00") + ".jpg", ImageFormat.Jpeg);

}

I get this error:

Parameter is not valid.

at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)

at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)

at Aspose.Slides.Pptx.SlideEx.GetThumbnail(Single scaleX, Single scaleY)

Here is the code that works for normal PPT slides:

Presentation pres = new Presentation(sPath + Path.DirectorySeparatorChar + filename);

for (int i = 1; i < pres.Slides.Count; i++)

{

//Accessing a slide using its slide position

Slide oSlide = pres.GetSlideByPosition(1);

//Getting the thumbnail image of the slide of a specified size

Image image = oSlide.GetThumbnail(new Size(1021, 781)); //new Size(1021,781)

//Saving the thumbnail image in jpeg format

image.Save(slideImagePath + "\\thumbnail" + i.ToString("00") + ".jpg", ImageFormat.Jpeg);

}

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

Thanks for considering Aspose.Slides.

The exception that you are encountering is due to wrong values entered in the arguments of following code snippet posted by you. Please make sure that the maximum values that each argument can hold are 1f.

//Getting the thumbnail image of the slide of a specified size

Bitmap image = oSlideEx.GetThumbnail(1021, 781); //new Size(290, 230)

Please try using following code snppet:

Bitmap image = oSlideEx.GetThumbnail(1f, 1f);

Bitmap image = oSlideEx.GetThumbnail(new Dimension(1021, 781) );

Thanks and Regards,