python-pptx
python-pptx copied to clipboard
added Slides.remove_slide(slide_id)
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)