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

Free Support Forum - aspose.com

How can I make a chart (image) to fill up body of you Aspose template slide?

I am evaluating your Aspose.Slide. I took your sample code and created charts with Aspose.Chart.
I save the charts as Bitmaps and insert the image to you Aspose template slide.
My problem is that I do know how to position and resize the image so that it fills up the body of the template. Most of the codes and the template slide I use are from examples I found on your website.

Would you please tell me how to fill up the body with an image?
I am attaching the code and slides.
bad.ppt is the one produced by the code
good.ppt is the result I want. I created this one by resizing and repositioning the image manually.
InsertingCharts.cs is the C# code I used from your examples.


Dear lajolla,

You have two options to add image, one as a slide background and other as a picture frame.

To add image as a slide background, follow this link.


To add image as a picture frame, follow this link


When you add the image in a picture frame, you can position it and also you can resize it.

Thanks very much for your help.

Yes. I did follow the example of adding a picture frame. I was wondering if there was a good way to fit the picture onto the body below the Aspose company logo.

I ended up putting in a hard coded adjustment (by the height of the Aspose banner at the top of the template) to move the picture lower so not to cover the Aspose banner at the top of the slide.

I was hoping there was a way to fit it without a hardcoded number that I find out trial and error.

int slideWidth = slide.Background.Width;
int slideHeight = slide.Background.Height - 800; // 800 is the adjustment

//Calculating picture width and height
int imageWidth = pres.Pictures[picId - 1].Image.Width;
int imageHeight = pres.Pictures[picId - 1].Image.Height;
double ratio = Math.Min(slideWidth / imageWidth, slideHeight / imageHeight);
int pictureWidth = (int) (slideWidth);
int pictureHeight = (int)(slideHeight);

//Calculating the width and height of picture frame
int pictureFrameWidth = Convert.ToInt32(slideWidth / 2 - pictureWidth / 2); // x pos
// 800 is the adjustment
int pictureFrameHeight = Convert.ToInt32(slideHeight / 2 - pictureHeight / 2 + 800); // y pos

//Adding picture frame to the slide
PictureFrame pf = slide.Shapes.AddPictureFrame(picId, pictureFrameWidth,
pictureFrameHeight, pictureWidth, pictureHeight);

You can also find the height and width of slide via Presentation.SlideSize.Width/Height properties.