Free Support Forum - aspose.com

Slide background image

I cannot get either a slide nor the main master to accept a background image. This is what I am doing:

Presentation report = new Presentation(reportReaderStream);
FillFormat fill=report.MainMaster.Background.FillFormat;

MemoryStream stream = null;
int pictureId;
try {
stream = new MemoryStream();
image.Save(stream, ImageFormat.Bmp);
Picture pict = new Picture(report, stream);
pictureId = report.Pictures.Add(pict);
}

finally {
if (stream != null)
stream.Close();}

fill.PictureId = pictureId;

fill.Type = FillType.Picture;

But the picture is always blank, and according to the debugger fill.PictureId retains its zero value instead of being updated to the value of pictureId.

I've tried setting slide.background.pictureid but that doesn't help either. I've tried this for the main master, and on individual slides with FollowMasterBackground set to false but it does not work.

I can add a picture frame and send it to the back, and that works. Is it because I’m using the trial version?

Trial version doesn’t have any limitations except watermark.

Please check Wiki page: http://www.aspose.com/Wiki/default.aspx/Aspose.PowerPoint/SlideProperties.html

and find differencies between example and your code.



slide.FollowMasterBackground = false;
slide.Background.FillFormat.Type = FillType.Picture;
Picture pic1 = new Picture(pres, MapPath(".") + "/images/RedWater.jpg");
int picid = pres.Pictures.Add(pic1);
slide.Background.FillFormat.PictureId = picid;

You should set FillFormat.PictureId after FillFormat.Type.
Also don't forget to change FollowMasterBackground for slides.

It was because I was setting the id before setting the fill type. Thanks.

I wasn't sure if perhaps the water mark was occluding the background.