I am creating power point 2007 files using the openxml. I am able to add slides, shapes, text and manipulate them to create custom reports. However, I can not find an example on how to dynamically load an image into my power points. In principle I imagine that it would involve adding the image as a resource and then adding a reference to that resource. Any example code would be great help.
Thank you.
You will first need to add an ImagePart to your SlidePart like this:
ImagePart imagePart = slidePart.AddImagePart(ImagePartType.Png, "rId3");
The "rId3"
needs to be the relationshipId that corresponds to your image that you are adding to the presentation. You could also leave that parameter blank and a default relationship id will be created for you. Next you need to feed that image part the actual image:
imagePart.FeedData(new MemoryStream(photo.ToArray()));
If you are still having trouble take a look at these two blog posts. They both show some code mid way down about adding photos to a presentation.
Creating a report presentation based on data
Adding repeating data to PowerPoint
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With