Skip to content

[Content_Types].xml not getting updated on PresentationDocument.Save with all FontParts removed #1551

Description

@JessehMSFT

Describe the bug
I'm using OpenXML SDK to disable font embedding and remove all FontParts in a presentation. Saving the document isn't resulting in [Content_Types].xml getting updated even though no more fntdata parts exist in the file.

To Reproduce
Steps to reproduce the behavior:

  1. Download ClearEmbedFontsFlag.zip
  2. Run the below code using the included pptx as input
        internal static void RemoveEmbeddedFontsMin(string file)
        {
            using PresentationDocument doc = PresentationDocument.Open(file, isEditable: true);
            PresentationPart? presentationPart = doc.PresentationPart;
            if (presentationPart is null)
                return;

            BooleanValue? embedFonts = presentationPart.Presentation.EmbedTrueTypeFonts;
            if (embedFonts is null || !embedFonts.HasValue || !embedFonts.Value)
                return;

            presentationPart.Presentation.EmbedTrueTypeFonts = false;

            EmbeddedFontList? fontList = presentationPart.Presentation.EmbeddedFontList;
            if (fontList is not null)
            {
                presentationPart.Presentation.EmbeddedFontList = null;
                presentationPart.DeleteParts(presentationPart.FontParts);
            }

            doc.Save();
        }

Observed behavior
See EmbeddedFont - Copy.pptx for result.

When you inspect [Content_Types].xml, it still contains this entry:
<Default Extension="fntdata" ContentType="application/x-fontdata" />

Expected behavior
All fntdata parts have been removed. This entry is not nececssary.

If I switch to a SaveAs to a new file instead of a Save, the fntdata entry is removed from the resulting file.

If I open the file inside PowerPoint and let the app save, it also removes the unnecessary entry.

Desktop (please complete the following information):

  • OS: Windows
  • Office version: N/A
  • .NET Target: .Net 6.0
    • DocumentFormat.OpenXml Version: 2.20.0

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions