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..

using GemBox.Document;
class Program
{
static void Main()
{
// If using the 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 the 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
See also
Next steps
Published: September 22, 2021 | Modified: December 19, 2022 | Author: Marek Turis