-
Notifications
You must be signed in to change notification settings - Fork 575
Open
Milestone
Description
Description
PresentationDocument.Save() doesn't apply changes that are deleting presentation sections. It works if I call doc.Close() (check Repro), but I don't wanna close presentation before mStream.ToArray().
Looks like PresentationDocument.Save() doesn't flush changes to mStream stream.
Information
- .NET Target: .NET 6
- DocumentFormat.OpenXml Version: 2.16.0
Repro
using DocumentFormat.OpenXml.Office2010.PowerPoint;
using DocumentFormat.OpenXml.Packaging;
using var fStream = File.OpenRead(@"c:\temp\base.pptx");
var mStream = new MemoryStream();
fStream.CopyTo(mStream);
fStream.Close();
using var doc = PresentationDocument.Open(mStream, true);
var sectionList = doc.PresentationPart!.Presentation.PresentationExtensionList?.Descendants<SectionList>().First();
sectionList.Remove();
doc.Save();
// doc.Close() // it works
File.WriteAllBytes(@"c:\temp\edited.pptx", mStream.ToArray());
// ...Observed
edited.pptx still has section.
Expected
edited.pptx doesn't have sections.
Metadata
Metadata
Assignees
Labels
No labels