Multimedia information can be presented conveniently by using PowerPoint, and the information form is multimedia and expressive. But it is inevitable that in some cases we will need to convert PowerPoint to HTML format. Because HTML documents can be independent of various operating system platforms (such as Unix, Windows, etc.). And it can add content such as pictures, sounds, animations, videos, etc., and can also jump from one file to another, and connect with files on hosts around the world. Through HTML, rich and colorful design styles can be displayed, jumps between pages can be realized, and multimedia effects can be displayed. This article will introduce in detail how to convert PowerPoint to HTML through C#/VB.NET code.
- Convert a PowerPoint Presentation to HTML
- Convert a Specific PowerPoint Slide to HTML
Programming Environment
In this test, Free Spire.Presentation for .NET is introduced into the program. The Spire.Presentation.dll file can be referenced by:
Method 1: Download Free Spire.Presentation for .NET locally, unzip it, and install it. After the installation is complete, find Spire.Presentation.dll in the BIN folder under the installation path. Then open the "Solution Explorer" in Visual Studio, right-click "References", "Add Reference", and add a reference to the dll file in the BIN folder of the local path to the program.
Method 2: Install via NuGet. It can be installed by the following 2 methods:
(1) You can open the "Solution Explorer" in Visual Studio, right-click "References", "Manage NuGet Packages", then search for "Free Spire.Presentation ", and click "Install". Wait for the program installation to complete.
(2) Copy the following content to the PM console installation.
Install-Package
FreeSpire.Presentation -Version 7.8.0
Convert a
PowerPoint Presentation to HTML in C# and VB.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:
- 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.
Full Code
C#
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(@"Jupiter.pptx");
//Specify the file path of the output HTML file
String result = "D:\\.NET\\PowerPoint\\PowerPointToHtml0.html";
//Save the PowerPoint presentation to HTML format
ppt.SaveToFile(result,
FileFormat.Html);
}
}
}
VB.NET
Imports Spire.Presentation
Namespace
ConvertPowerPointToHtml
Friend Class Program
Private Shared Sub Main(ByVal args As String())
'Initialize an instance of the
Presentation class
Dim ppt As Presentation = New Presentation()
'Load a PowerPoint presentation
ppt.LoadFromFile("Jupiter.pptx")
'Specify the file path of the output HTML
file
Dim result = "D:\.NET\PowerPoint\PowerPointToHtml0.html"
'Save the PowerPoint presentation to HTML
format
ppt.SaveToFile(result, FileFormat.Html)
End Sub
End Class
End Namespace
Effective Shot
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. We can use 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.
Full Code
C#
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("Jupiter.pptx");
//Get the first slide
ISlide slide = presentation.Slides[2];
//Specify the file path of the output HTML file
String result = " D:\\.NET\\PowerPoint\\SpecificSlideToHtml.html";
//Save the first slide to HTML format
slide.SaveToFile(result,
FileFormat.Html);
}
}
}
VB.NET
Imports Spire.Presentation
Namespace
ConvertPowerPointSlideToHtml
Friend Class Program
Private Shared Sub Main(ByVal args As String())
'Initialize an instance of the
Presentation class
Dim presentation As Presentation = New Presentation()
'Load the PowerPoint presentation
presentation.LoadFromFile("Jupiter.pptx")
'Get the first slide
Dim slide As ISlide = presentation.Slides(2)
'Specify the file path of the output HTML
file
Dim result = " D:\.NET\PowerPoint\SpecificSlideToHtml.html"
'Save the first slide to HTML format
slide.SaveToFile(result, FileFormat.Html)
End Sub
End Class
End Namespace
Effective Shot
Conclusion:
In
this post, you have learned how to convert PowerPoint to HTML in C#/VB.NET. Not
only that, we also have other functions, such as, C#/VB.NET:
Convert Images (PNG, JPG, BMP, etc.) to PowerPoint, C#/VB.NET:
Convert PowerPoint Presentations to PDF and so on. Apart from
that, if you'd like to learn more, you can visit this link to explore more about for
Spire.Presentation for .NET.
Comments
Post a Comment