Adding an image to a slide in Version 6 of the library - no documentation available

Hi All,


I have been spoilt and used the latest verison of the ASPOSE.Slides library… then reality hit when I had to use my companies purchased version 6 and discovered that my current syntax isn’t supported in the older version.

Please would anyone mind translating the following method (PresentationExport()) into using version 6 of the library. I have included the private method SVGToPNG() for completeness :-):

public string PresentationExport(String base64Data, int width, int height, string basePath, string baseURL)
{
//Create Image from base64 Data passed into method
Image image = SVGToPNG(base64Data);

using (Presentation pres = new Presentation())
{

//Get the first slide
ISlide sld = pres.Slides[0];

//Instantiate the ImageEx class
IPPImage imgx = pres.Images.AddImage(image);

//Add Picture Frame with height and width equivalent of Picture
int positionX = (int)((720 / 2) - ((width / 1.78) / 2));
int positionY = 50;
int imageHeight = (int)(height / 1.78);
int imageWidth = (int)(width / 1.78);

sld.Shapes.AddPictureFrame(ShapeType.Rectangle, positionX, positionY, imageWidth, imageHeight, imgx);

string Filename = Guid.NewGuid().ToString() + “.pptx”;

pres.Save(basePath + Filename, Aspose.Slides.Export.SaveFormat.Pptx);

return baseURL + Filename;

}

}


private Image SVGToPNG(String base64Data)
{
byte[] bytes = Convert.FromBase64String(base64Data);

Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = Image.FromStream(ms);
}
return image;

}


Thank you very much for you time and valuable expertise.

Kind Regards,

Richard

Hi Richard,

Thank you for the details.

You can download the offline documentation of the old version using the below link.

Aspose.Slides for .NET Old Documentation

Also, following is the code which you can modify to use at your end.

//Instantiate PresentationEx class that represents the PPTX

using (PresentationEx pres = new PresentationEx())

{

//Get the first slide

SlideEx sld = pres.Slides[0];

//Instantiate the ImageEx class

System.Drawing.Image img = (System.Drawing.Image)new Bitmap("d:\\pptx\\asp.jpg");

ImageEx imgx = pres.Images.AddImage(img);

//Add Picture Frame with height and width equivalent of Picture

sld.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);

//Write the PPTX file to disk

pres.Write("d:\\pptx\\RectPicFrame.pptx");

}

In case you need any further assistance, please feel free to contact support.

Thanks & Regards,

Thank you Owais, this worked perfectly.


Kind Regards,

Rich