I was looking at using sections in my “Template” PPTX to allow a little more flexibility to clone multiple slides that are related. I have not been able to find a way to get a section of a powerpoint in Gembox. Is this a thing that can be done?
Any help would be greatly appreciated.
Cheers,
Nathan
GemBox.Presentation currently doesn’t provide API support for sections.
However, we have decided that we will implement this feature for you.
I will contact you again soon.
Or this NuGet package: Install-Package GemBox.Presentation -Version 25.0.1136-hotfix
We added support for PresentationDocument.Sections collection. For your use case, you can use something like the following to iterate through slides of some specific section:
The Section can define the first slide with which it begins (Section.FirstSlide), and it ends before the first slide of the next section (or the end of the presentation).
So, to put the slide into a section, you need to move it between the first slide of the section that you’re targeting and the first slide of the next section.
For example, try the following:
var presentation = new PresentationDocument();
for (int i = 0; i < 10; i++)
presentation.Slides.AddNew(SlideLayoutType.Custom)
.Content.AddShape(ShapeGeometryType.RoundedRectangle, 100, 100, 100, 100)
.Text.AddParagraph().AddRun("Slide " + i);
presentation.Sections.AddNew("Section 0-2", presentation.Slides[0]);
presentation.Sections.AddNew("Section 3-5", presentation.Slides[3]);
presentation.Sections.AddNew("Section 6-9", presentation.Slides[6]);
// Move "Slide 8" before "Slide 1", as a result, the slide is moved from "Section 6-9" to "Section 0-2".
var slide8 = presentation.Slides[8];
presentation.Slides.Remove(slide8);
presentation.Slides.Insert(1, slide8);
presentation.Save("output.pptx");