Hi,
I’m trying to remove all shapes form a slide or multiple slides.
I tried the code below for multiple times,only to find that only few shapes were removed.
Shapes like text frame,picture frame,video frame and group shapes still exsit.
I’ve heard that the possible culprit that caused this is the changing indices.But I still can’t figure out how to fix this.
Please tell me how I can remove all shapes form slides.
Thanks and Regards
I’ve reproduced the problem with removing shapes from slides and added a ticket with ID SLIDESNET-43504 to our issue tracking system. We apologize for any inconvenience. Our development team will investigate the case. You will be notified when a new release of Aspose.Slides with a fix is published.
It would be great if you could share the following additional data and information:
Thanks for your reply.
By the way,may I ask you if there is a way to fix this issue temporarily?
For example,can I just write code to delete different types of shapes respectively?
@Loui,
To remove a shape by a specified type, you can instantiate a collection of the shapes, enumerate it, and check the type of shapes as shown below:
using var pres = new Presentation("example.pptx");
foreach (var slide in pres.Slides)
{
var shapeCollection = new List<IShape>(slide.Shapes);
foreach (var shape in shapeCollection)
{
if (shape is IGroupShape groupShape) // for example
{
slide.Shapes.Remove(shape);
}
}
}
pres.Save("output.pptx", SaveFormat.Pptx);