scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.4k stars 519 forks source link

feature request: possibility to duplicate shapes and slides, and add them to a new presentation #913

Closed dportabella closed 1 year ago

dportabella commented 1 year ago
import pptx

prs_src = pptx.Presentation('example.pptx')
prs_dst = pptx.Presentation()

slide_to_copy = prs_src.slides[0]

# prs_dst.slides.add_slide(slide_to_copy)  # this does not work

new_slide = prs_dst.slides.add_slide(prs_dst.slide_layouts[1])
for shape in slide_to_copy.shapes:
    new_slide.shapes.add_shape(shape.clone())  # this does not work

prs_dst.save('output.pptx')
scanny commented 1 year ago

Duplicate of #533 and #132.

@dportabella feel free to elaborate on or vote-up those issues if you like. It turns out to be a pretty heavy lift to do this in the general case, mostly because of embedded objects like charts and images that are linked to separate "files" (package parts) and need presentation-specific ids, so a raw copy doesn't get one very far.

dportabella commented 1 year ago

I see is is non trivial. I think it is a useful feature. Do you maintain a list of feature requests? maybe you can add such a list of feature requests in the README.md page, so that someone may collaborate on this. Thanks for sharing this project. 🙏

scanny commented 1 year ago

There are a great many feature requests. Look for open issues with a gray tag, like table, text, etc. There would be too many to catalog in README.md. Word turns out to have an extremely broad functionality space :)