We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert HTML to MHTML using C# and VB.NET

Platform: WinForms |
Control: PDF |
Published Date: October 29, 2018 |
Last Revised Date: June 16, 2020
Tags: pdf, c#, html, mhtml, vb.net

Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can convert HTML to MHTML using advanced Qt WebKit rendering engine in C# and VB.NET. Qt WebKit rendering is accurate, and the result preserves all the graphics, images, texts, fonts, and the layout of the original HTML document/webpage.

Assemblies required

  • Syncfusion.Compression.Base.dll
  • Syncfusion.Pdf.Base.dll
  • Syncfusion.HtmlConverter.Base.dll
  • QtBinaries folder

You can get all the previously mentioned assemblies by installing the WebKit installer available in the following link.

WebKit HTML converter: https://www.syncfusion.com/downloads/latest-version

Steps convert HTML to MHTML programmatically:

  1. Create a new C# console application project.

Create console application project

  1. Install the Syncfusion.HtmlToPdfConverter.QtWebKit.WinForms NuGet package as reference to your .NET framework application from NuGet.org. NuGet reference
  2. Include the following namespaces in the Program.cs file.


using Syncfusion.HtmlConverter;



Imports Syncfusion.HtmlConverter


  1. Use the following code snippet to convert HTML to MHTML.


//Initialize HTML converter with WebKit rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Set WebKit path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings;
//Convert URL to MHTML
htmlConverter.ConvertToMhtml("http://www.google.com", "sample.mhtml");



'Initialize HTML converter with WebKit rendering engine
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
Dim webKitSettings As New WebKitConverterSettings()
'Set WebKit path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings
'Convert URL to MHTML
htmlConverter.ConvertToMhtml("http://www.google.com", "sample.mhtml")


You can download the work sample from HtmlToMHtmlSample.zip.

Output document screenshot

By executing the program, you will get the MHTML file as follows.

Take a moment to peruse the documentation, where you can find other options like MHTML to PDF, HTML to Raster Image, Partial webpage to Raster Image, HTML to SVG, and Partial Webpage to SVG with code examples.

Refer here to explore the rich set of Syncfusion Essential PDF features.


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile