python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

Feature Request: Add shapes to Slide Master

Open marcrsc opened this issue 6 years ago • 11 comments

Hello!

Sometimes we may need to customize the Master Slide to provide a really custom presentation, changing the background, a client's logo, include some fixed text, etc. Although we can insert this background and logo slide by slide, it is inefficient, and not so elegant...

I could see some workarounds suggesting replacing images in the master slide from a previous model (I could not make it work, it is in another thread), but it still requires a previously structured base presentation. The ideal is to be able to freely create this slide master runtime, from a totally blank presentation (including a blank master).

Trying to insert a shape using the command below returns an error: "AttributeError: 'MasterShapes' object has no attribute 'add_picture'", informing that it is not implemented:

prs = Presentation()
slide=prs.slide_master
img = slide.shapes.add_picture(image1, left, top, width, height)

I think that technically it is possible, considering Powerpoint specs because using Delphi I can customize the master slide simply adding shapes. It has some wrapper components that encapsulate some Microsoft APIs and there are working commands like this:

PPT.SlideMaster.Shapes.AddPicture(image1, 1, 1, left, top, width, height);

But the idea is to do that using Python with python-pptx, because Delphi requires Powerpoint installed and running in the machine to work (the app actually open - who creates the presentation is Powerpoint itself, the API just controls it) - this makes python-pptx much more practical and powerful, especially when generating presentations in a server.

Is there some way to insert texts, pictures, and other shapes to Master Slide? If not, is it possible to implement it in a near feature?

Thanks and regards!

marcrsc avatar Nov 30 '19 21:11 marcrsc