Remove all unused Slide Layout from my Master Slide from Powerpoint Presentation using OpenXML SDK

Viewed 127

I'm currently working on editing my existing PowerPoint file (.pptx) using OpenXML SDK. Can I know how to remove all unused (unlinked) Slide Layouts from my PowerPoint presentation?

The reason for this is I want to reduce the PPTX file and I have 100+ unused layouts.

Thank you.

1 Answers

It looks like with OpenXML SDK you need to parse all slides and/or slide layouts and check relationships between them. On the other hand, this can be easily done with Aspose.Slides for .NET:

using var presentation = new Presentation("input.pptx");
presentation.LayoutSlides.RemoveUnused();
presentation.Save("output.pptx", SaveFormat.Pptx);

I work as a Support Developer at Aspose.

Related