Convert MHT to PDF File in C#

MHT MHTML to PDF csharp

MHT file is a webpage archive format that includes text, graphics, animations, CSS, JavaScript, and all linked resources in a single file. Some webpages access images or other resources from a server and saving the page in MHT or MHTML format will let you see such contents even when you are offline. In certain cases, you may need to convert an MHT file to PDF format. This article covers how to convert an MHT file to a PDF file in C#.

MHT to PDF Converter – C# .NET API Installation

Aspose.HTML for .NET API supports creating, editing, or manipulating HTML, MHTML, and other supported file formats. You can access the API by downloading its DLL files from the Downloads section or using the following NuGet installation command:

PM> Install-Package Aspose.Html

Convert MHT or MHTML to PDF in C#

MHT files are usually saved with a .mhtml file extension. You can convert an MHT or MHTML file to a PDF file with the following steps:

  1. Create an object of the PdfSaveOptions class.
  2. Convert the MHT or MHTML to PDF with ConvertMHTML method.

The code snippet below demonstrates how to convert an MHT or MHTML file to PDF programmatically in C#:

Explore Aspose.HTML for .NET API

You can learn several features to work with web pages by exploring the documentation section. It covers different features including file conversions, web crawling, etc.

Get Free License

You may try working with the API in its full capacity by getting a free temporary license.

Conclusion

In this article, you have learned how to convert an MHT or MHTML file to PDF format in C# or .NET framework-based applications. In case of any questions, please feel free to write to us at the forum.

See Also

Convert YouTube to MP3 in C#