Hi,
I would like to take a shape that is a PictureFrame, and save it to a file.
I tried serializing the shape to a stream, and writing the stream to disk, but it is not recognized as any file type, even with an extension, that I tried appending to the filename(.jpeg, .png, or .wmf).
Can you help? Here is my code snippet:
using (Stream stream = File.Create(newfileName)){
(shape as Aspose.Slides.PictureFrame).Serialize(stream);
}
Thanks,
Karen Schmidt
Hi Karen,
Thanks for your interest in Aspose.Slides.
Please use the code snippet below, that will help in finding a shape that is a PictureFrame and store that shape as Jpeg image. You can also visit this link for further information. Please find the attached demo presentation and generated Jpeg file.
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation("D://ppt//demo.ppt");
//Accessing a slide using its slide position
Slide slide = pres.GetSlideByPosition(1);
//Iterate all shapes on a slide and create thumbnails
Shapes shapes = slide.Shapes;
// Traversing throuhg all shapes in slide
for (int i = 0; i < shapes.Count; i++)
{
Shape shape = shapes[i];
//Getting the thumbnail image of the shape
if (shape is PictureFrame)
{
//Getting picure frame in Image
System.Drawing.Image img = slide.GetThumbnail(new object[] { shape }, 2.0, 2.0, shape.ShapeRectangle);
//Saving the thumbnail image in Jpeg format
img.Save("d://ppt//demo.Jpeg", ImageFormat.Jpeg);
}
// System.Drawing.Imaging.
}
}
Thanks and Regards,