Convert HTML to JPG in C#
PowerPoint .NET API for converting HTML files to JPG images on NET Framework, .NET Core, Windows Azure, Mono or Xamarin Platforms
Convert HTML to JPG in C#
How do I convert HTML to JPG in code?
Using Aspose.Slides for .NET , any developer or application can convert HTML to JPG format with just a few lines of C# code.
As a modern document processing API, Aspose.Slides for .NET exports HTML files to JPG quickly. Aspose PowerPoint library allows you to convert HTML to JPG and many other file formats
To install Aspose.Slides: Open NuGet package manager. Search for Aspose.Slides and install it.
Or you can install Aspose.Slides by running this command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Slides.NET
How to Convert HTML to JPG in C#
Developers and applications can convert HTML to JPG this way:
Create an instance of the Presentation class.
Load the HTML file.
Add slides based on the content in the HTML document.
Save the slides as JPG images.
System Requirements
Before you run the HTML to JPG conversion C# code, your machine must have these prerequisities:
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Windows Azure, Mono or Xamarin Platforms.
- Development environment like Microsoft Visual Studio.
- Aspose.Slides for .NET DLL has been referenced in your project.
C# code to convert HTML to JPG
using (Presentation pres = new Presentation())
{
pres.Slides.AddFromHtml("page.html");
pres.Slides.RemoveAt(0); // removes default empty slide
for (var index = 0; index < pres.Slides.Count; index++)
{
ISlide slide = pres.Slides[index];
slide.GetThumbnail(new Size(960, 720)).Save($"image-{index}.jpg", ImageFormat.Jpeg);
}
}
Free Online Converter
Other Supported Conversions
Aspose.Slides supports conversion operations for many file formats