Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Slides.remove_slide(slide_id) #1029

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RaulSofia
Copy link

@RaulSofia RaulSofia commented Nov 16, 2024

Adds the delete slide feature. You can do this by calling the method Slides().remove_slide(slide_id) on a Slides instance. It deletes a slide and relations, doing just the opposite of the routines in add_slide(). This function calls PresentationPart().remove_slide(slide_id) and CT_SlideIdList().remove_sldID(slide_id), which were also added here. It raises a KeyError(f"no slide with id {slide_id}") if the specified slide_id does not exist.

Fixes issue #67

Example usage:

from pptx import Presentation

presentation = Presentation()
presentation.slides.add_slide(presentation.slide_layouts[6])
presentation.slides.remove_slide(presentation.slides[-1].slide_id) #removes last slide
presentation.save("my_presentation.pptx")

#output: empty presentation (no slides)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant