Detect the used themes in PowerPoint in C#

2018-09-07 07:20:49 Written by  support iceblue
Rate this item
(0 votes)

This article demonstrates how to detect the used themes in a PowerPoint document using Spire.Presentation.

Detail steps:

Step 1: Instantiate a Presentation object and load the PowerPoint document.

Presentation ppt = new Presentation();
ppt.LoadFromFile(@"Sample.pptx");

Step 2: Get the theme name of each slide in the document.

StringBuilder sb = new StringBuilder();
string themeName = null;

foreach (ISlide slide in ppt.Slides)
{
    themeName = slide.Theme.Name;
    sb.AppendLine(themeName);
}

Step 3: Save to a .txt file.

File.WriteAllText("themeName.txt", sb.ToString());

Output:

Detect the used themes in PowerPoint in C#

Full code:

using Spire.Presentation;
using System.IO;
using System.Text;
namespace DetectThemes 
{
    class Program
    {
        static void Main(string[] args)
        {
            //Instantiate a Presentation object
            Presentation ppt = new Presentation();
            //Load the PowerPoint document
            ppt.LoadFromFile(@"Sample.pptx");

            StringBuilder sb = new StringBuilder();
            string themeName = null;

            //Get the theme name of each slide in the document
            foreach (ISlide slide in ppt.Slides)
            {
                themeName = slide.Theme.Name;
                sb.AppendLine(themeName);
            }

            //Save to a .txt file
            File.WriteAllText("themeName.txt", sb.ToString());

            }
        }
    }

Additional Info

  • tutorial_title:
Last modified on Friday, 24 September 2021 09:12