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 the Professional version, put your serial key below.

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

        // Save output PDF file.
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using the Professional version, put your serial key below.

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

        ' Save output PDF file.

    End Sub
End Module

See also

Next steps

GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API. How about testing it today?

Download Buy