Replies: 5 comments 17 replies
-
"empty sections" is not clear. Could you provide a little bit more details? Is it an empty shape? Would be could if you attach pptx-file sample. |
Beta Was this translation helpful? Give feedback.
-
Currently, section handling is not supported by ShapeCrawler. By the way, this is a good feature for future versions! You can you use the following code sample to remove empty sections with pure Open XML SDK: using DocumentFormat.OpenXml.Office2010.PowerPoint;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Presentation;
const string pptxPath = @"c:\temp\test.pptx";
using var doc = PresentationDocument.Open(pptxPath, true);
var sectionList = doc.PresentationPart!.Presentation.PresentationExtensionList?.Descendants<SectionList>().First();
if (sectionList == null)
{
return; // presentation doesn't have sections
}
// Remove empty sections
foreach (Section section in sectionList)
{
var isEmptySection = !section.Descendants<SlideId>().Any();
if (isEmptySection)
{
section.Remove();
}
} I tested this code on just a few test cases. Let me know if it doesn't work for you. |
Beta Was this translation helpful? Give feedback.
-
So I was able to achieve the requirement, here is the complete API. Thanks for your help !
|
Beta Was this translation helpful? Give feedback.
-
@adamshakhabov - Is there any way I can have a MemoryStream of updated PPT from OpenXML ? I want to upload it in sharepoint but when I'm opening the file from MemoryStream and after deleting empty sections when I'm saving it my changes are not there.
|
Beta Was this translation helpful? Give feedback.
-
Presentation sections handling was added in v0.30.0 release. |
Beta Was this translation helpful? Give feedback.
-
How to delete empty sections from powerpoint file with ShapeCrawler nuget package?
Beta Was this translation helpful? Give feedback.
All reactions