HTML Conversion online or via C#

Convert HTML to PDF, XHTML, MHTML, Markdown, XPS, DOCX and Images

How to Convert HTML Using C#

Hypertext markup language HTML is the language of the Web. Currently, most information is present on websites in form of webpages. So converting this HTML-based information into other formats like PDF, XPS, Microsoft® Word, Markdown and image formats is a common scenario. .NET HTML API makes the conversion process easier for developers. It loads the file using HTMLDocument class, creates the relevant save options object and uses the Converter class relevant conversion method.

Any conversion you want to perform involves loading an HTML document and saving it in the supported format. It can be different scenarios, but it can be made with a few required steps:

  1. Load an HTML document into a Document object using one of HTMLDocument() constructors. You can load HTML from a file, HTML code, stream, or URL.
  2. Create a Save Options object.
  3. Invoke one of the ConvertHTML() methods and pass the required parameters to it.

Online HTML Converter

You can convert HTML with Aspose.HTML for .NET API in real-time. The following C# example demonstrates how to convert an HTML document. Please load a file from a local file system or URL, select the output format and run the example. You will immediately get the result. You can try Free Online Converters here.

Conversion functions in the documentation

The main highlight of Aspose.HTML .NET API is a conversion feature. Converting between formats is required for various reasons: to work in a familiar, convenient format or to take advantage of different formats for specific tasks. The Aspose.Html.Converters namespace implements easy access to conversion methods. It provides a wide range of HTML conversions to popular formats, such as PDF, XPS, DOCX, JPEG, PNG, BMP, TIFF, GIF, MHTML, and MD. Please visit the documentation chapter Converting Between Formats to learn more about Aspose.HTML for .NET API conversion features.

Installing Aspose.HTML for .NET library

This library supports parsing of HTML5, CSS3, SVG and HTML Canvas to construct a Document Object Model (DOM) based on the WHATWG DOM Standard. You can use several ways to install the Aspose.HTML library for .NET on your system:

  1. Using the NuGet Package Manager GUI.
  2. Using the Package Manager Console.
  3. Installing Aspose.HTML for .NET through MSI.

For more details about C# library installation, please refer to Aspose.HTML Documentation .

Other Supported Conversions

You can also convert HTML, XHTML, MHTML, EPUB, Markdown, and SVG files into many other file formats including few listed below: