scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.45k stars 528 forks source link

Input for powerpoint automation #465

Open swami3333 opened 5 years ago

swami3333 commented 5 years ago

When I talked about automation, this is one of the projects we need help in.

Our Persistent PowerPoint Presentation Service team currently has to upgrade the badly designed inconsistent slide decks that come in and make them consistent with brand guidelines and improve overall look and feel. They also correct basic spelling and grammar and make the spellings consistent. The way they do it is to try and apply the approved Master template to the input. It sounds simple enough, but is a little clumsy. (Applying a master by our definition would roughly result in the look and feel of the master (the opening slide, sections, thank you and colour palette, header, footer) transferring to this presentation.) The customer is working in PowerPoint 2013 as are we.

See the sample input PowerPoint file (1483…._ Persistent System overview file attached). We want to be able to find a way to:

“Apply” the master template to any input that comes in seamlessly OR allow for all content transfer from input old template to new master template programmatically with a one to one slide correspondence (instead of a clumsy select all, copy paste from slide to slide) Applying a master by our definition would roughly result in the look and feel of the master (the opening slide, sections, thank you and colour palette, header, footer) transferring to this presentation.

Transport the notes with the slides Programmatically embed the theme, color palette, fonts and the smart art with the master template wherever it goes, negating the need for additional installation. 1483697969846_Persistent Systems Overview v2 - Jan 4 2017.pptx

swami3333 commented 5 years ago

I googled up and found out this code.

import os from pptx import Presentation

current_dir = os.path.dirname(os.path.realpath(file))

prs = Presentation(current_dir + '\input.pptx') title_slide_layout = prs.slide_layouts[0] slide = prs.slides.add_slide(title_slide_layout) title = slide.shapes.title subtitle = slide.placeholders[1]

prs.save('Output.pptx')

Is the above code correct for this problem statement. I ran the code and found it working. i.e It copies all input items to output items

Swami