Convert MHTML pages to PDF in C# and VB.NET

With GemBox.Document you can easily convert files between formats, using just C# or VB.NET code. You can use the component to load files in MHTML format and convert them to PDF.

Converting from MHTML to PDF programmatically with GemBox.Document is straightforward. You just need to load the MHTML file and set the output format to PDF.

Note that the supported features are the same as when using HTML format. You can find more information about reading HTML files in this example. Also, if you are trying to save a document to HTML, please take a look at the HTML import and export example.

The example below shows how to convert an MHTML file to a PDF format, separating the MHTML page into multiple pages in a PDF document..

Converted MHTML web page to PDF format in C# and VB.NET
Screenshot of input MHTML and converted output PDF
Upload your file (Drag file here)
using GemBox.Document;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        // Load input MHTML file.
        DocumentModel document = DocumentModel.Load("%InputFileName%");

        // Save output PDF file.
        document.Save("Output.%OutputFileType%");
    }
}
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        ' Load input MHTML file.
        Dim document As DocumentModel = DocumentModel.Load("%InputFileName%")

        ' Save output PDF file.
        document.Save("Output.%OutputFileType%")

    End Sub
End Module

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Document yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.