Get a List of Fonts From PowerPoint Using Open XML SDK

PowerPoint Get Fonts

Here is a quick code to get a list of fonts used within the PowerPoint using Open XML SDK 2.5. This code works only when the fonts are explicitly set for any elements. Fonts set within the Slide Master or Slide Layout cannot be extracted using the code below but you need to have a complex algorithm to find which fonts will be applied based on the Slide Master and Slide Layout. The following code snippet is just a starting point.

using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Presentation;
using A = DocumentFormat.OpenXml.Drawing;
using (PresentationDocument presentationDocument = PresentationDocument.Open("C:\\temp\\mypresentation.pptx", false))
    PresentationPart presentationPart = presentationDocument.PresentationPart;
    Presentation presentation = presentationPart.Presentation;
    foreach (var slideId in presentation.SlideIdList.Elements<SlideId>())
        SlidePart slidePart = presentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
        foreach (A.LatinFont font in slidePart.Slide.Descendants<A.LatinFont>())
            // font.Typeface.Value contains the font name 



2 responses to “Get a List of Fonts From PowerPoint Using Open XML SDK”

  1. Dev Kanaki Avatar
    Dev Kanaki

    is there any ways to get all font list without fonts available in the slide.

    1. Vishal Monpara Avatar
      Vishal Monpara

      Hello Dev,

      If the font is not set within individual site, you need to go to Slide Layout to get font information. If Slide Layout does not have font information, you need to go to Slide Master to get font information.

      Vishal Monpara

Leave a Reply

Your email address will not be published. Required fields are marked *