none
[PowerPoint C#] How to setup margins for background in PowerPoint slide? RRS feed

  • Question

  • PowerPoint let you set an offset for the background via UI.

    You can setup offsets from left, top, bottom and right. But I cant find a way to do it programatically. Im adding background like this:

    slide.Background.Fill.UserPicture("c:\temp\car.png");
    

    Background picture is stretched to fill the whole slide. I want to setup offsets (margins), how to do this?

    FillFormat object has fields TextureOffsetX and TextureOffsetY, but if I set them, image is treated as texture and tiled in the slide. This is not what I need.

    PS once more - I need margins for a background, not for a texture.

    Friday, September 26, 2014 11:50 AM

Answers

All replies

  • Hello Ules,

    The UserPicture method fills the specified shape with one large image. If you need to add an image with margins you have to add a shape (with margins) and then use the UserPicture method to fill the shape with your image.

    Saturday, September 27, 2014 12:08 PM
  • Hello Eugene,

       thanks a lot! Looks like shape's background can help me. Just wonder why there are no API for bacground margins, since they can be set via UI. Ill try your solution. Спасибо!

    Sunday, September 28, 2014 7:50 PM
  • Hi Ules,

    Based on my research, it seems that there isn’t the way to add margin to the background.

    You may use this code below to set background image for all slides.

    presentation.SlideMaster.Shapes.AddPicture(
                  path,   Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, 0, 0, slideWidth, slideHeight);

    Best Regards

    Starain Chen


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, September 29, 2014 8:26 AM
    Moderator