C#/VB.NET: Convert PowerPoint to HTML

When you share a PowerPoint presentation online, people have to download it to their computers before they can view it. Sometimes the downloading process can be quite annoying and time-consuming, especially when the file is very large. A good solution to this problem is to convert your presentation to HTML so that people can view it directly online. In this article, we will demonstrate how to programmatically convert PowerPoint presentations to HTML format in C# and VB.NET using Spire.Presentation for .NET.

Install Spire.Presentation for .NET

To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Presentation

Convert a PowerPoint Presentation to HTML in C# and VB.NET

In Spire.Presentation for .NET, the Presentation.SaveToFile(String, FileFormat) method is used to convert a PowerPoint presentation to other file formats such as PDF, XPS, and HTML. In the following steps, we will show you how to convert a PowerPoint presentation to HTML using Spire.Presentation for .NET:

  • Initialize an instance of the Presentation class.
  • Load a PowerPoint presentation using Presentation.LoadFromFile(String) method.
  • Save the PowerPoint presentation to HTML format using Presentation.SaveToFile(String, FileFormat) method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToHtml
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize an instance of the Presentation class
            Presentation ppt = new Presentation();
            //Load a PowerPoint presentation
            ppt.LoadFromFile(@"E:\Program Files\Sample.pptx");

            //Specify the file path of the output HTML file 
            String result = @"E:\Program Files\PowerPointToHtml.html";

            //Save the PowerPoint presentation to HTML format
            ppt.SaveToFile(result, FileFormat.Html);
        }
    }
}

C#/VB.NET: Convert PowerPoint to HTML

Convert a Specific PowerPoint Slide to HTML in C# and VB.NET

In some cases, you may need to convert a specific slide instead of the whole presentation to HTML. Spire.Presentation offers the ISlide.SaveToFile(String, FileFormat) method to convert a PowerPoint slide to HTML. The following are the detailed steps:

  • Initialize an instance of the Presentation class.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Get a specific slide in the PowerPoint presentation by its index through Presentation.Slides[int] property.
  • Save the PowerPoint slide to HTML format using ISlide.SaveToFile(String, FileFormat) method.
  • C#
  • VB.NET
using Spire.Presentation;
using System;

namespace ConvertPowerPointSlideToHtml
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize an instance of the Presentation class
            Presentation presentation = new Presentation();
            //Load the PowerPoint presentation
            presentation.LoadFromFile(@"E:\Program Files\Sample.pptx");

            //Get the first slide
            ISlide slide = presentation.Slides[0];

            //Specify the file path of the output HTML file 
            String result = @"E:\Program Files\SlideToHtml.html";

            //Save the first slide to HTML format
            slide.SaveToFile(result, FileFormat.Html);
        }
    }
}

C#/VB.NET: Convert PowerPoint to HTML

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.