none
Removing Embedded Fonts RRS feed

  • Question

  • Hey,

    I was looking for a way to remove one or more embedded fonts within a document. Is this possible? I figured I could set the font table to null, but I'd imagine the fonts will still be in the file itself.

    Help would be appreciated!

    Saturday, January 5, 2019 5:58 PM

Answers

  • Did it! Although I didn't end up removing one single font, instead this removes all fonts from the font table.

                    var fontParts = doc.MainDocumentPart.Parts
                        .Where(x => x.OpenXmlPart.ContentType.Contains("font", StringComparison.OrdinalIgnoreCase))
                        .Select(x => x.OpenXmlPart)
                        .ToArray();
                    if (fontParts.Any())
                        doc.MainDocumentPart.DeleteParts(fontParts);

    • Marked as answer by Still34 Sunday, January 6, 2019 12:36 AM
    Sunday, January 6, 2019 12:36 AM