Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Tue Dec 11, 2018 8:00 am

When I created a new PowerPoint from Spire.Presentation, I see one master slide with 11 layout slides under that. Is it possible to programatically delete these layout slides from Master slides that are unused? Please let me know. Thanks!

prven
 
Posts: 5
Joined: Thu Aug 23, 2018 5:13 am

Tue Dec 11, 2018 9:21 am

Hi prven,

Thanks for your inquiry.
Sorry that Spire.Presentation doesn't support that at present. We will consider adding the new feature in our future upgrade. Once there is any good news, we will let you know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Dec 24, 2018 7:02 am

Hi prven,

Glad to inform you that Spire.Presentation supports deleting MasterSlide layout now. Please download Spire.Presentation Pack Hotfix Version:3.12.4 and here is the new feature code:
Code: Select all
                IMasterLayouts.RemoveMasterLayout(i);

For deleting the unused layout, please refer to following code:

Code: Select all
            Presentation ppt = new Presentation();
            IMasterSlide masterSlide = ppt.Masters[0];
            ppt.Slides.Append();
            for (int a = ppt.Masters.Count - 1; a >= 0; a--)
            {
                IMasterLayouts mlayouts = ppt.Masters[a].Layouts;
                ArrayList list = new ArrayList();
                for (int b = 0; b < ppt.Slides.Count; b++)
                {
                    var masterSlideID = ppt.Slides[b].MasterSlideID;
                    ActiveSlide layout = (ActiveSlide)ppt.Slides[b].Layout;
                    if (ppt.Masters[a].SlideID == masterSlideID)
                    {
                        for (int c = mlayouts.Count - 1; c >= 0; c--)
                        {
                            ActiveSlide mlay = (ActiveSlide)mlayouts[c];
                            if (layout.SlideID == mlay.SlideID)
                            {
                                if (!list.Contains(c)) list.Add(c);
                            }
                        }
                    }
                }
                for (int i = mlayouts.Count - 1; i >= 0; i--)
                {
                    //delete the master layout
                    if (!list.Contains(i))
                        mlayouts.RemoveMasterLayout(i);
                }
                //delete the master
                if (mlayouts.Count == 0)
                    ppt.Masters.RemoveAt(a);
            }
            ppt.SaveToFile("15846.pptx", FileFormat.Pptx2010);


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Sat Dec 29, 2018 6:02 am

Hi,

Greetings from E-iceblue.
Do you use the hotfix and the new feature? Has your issue been resolved?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Jan 03, 2019 7:08 am

Yes, the hotfix worked out good and our issue is resolved. Thank you!

prven
 
Posts: 5
Joined: Thu Aug 23, 2018 5:13 am

Thu Jan 03, 2019 7:17 am

Hi,

Thanks for your feedback.
Any question, welcome to get it back to us.
Have a nice day :)

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Presentation