MHTML Converter – Convert MHTML in C#

Use the MHTML Converter guides when your source is a single-file web archive. Aspose.HTML for .NET converts MHTML streams or files to PDF, XPS, DOCX, JPG, PNG, BMP, TIFF, and GIF in C#.

MHTML stores HTML markup and related resources in one archive file, which makes it useful for saved web pages, email-like archives, and portable snapshots. In Aspose.HTML for .NET, MHTML conversion usually reads the source as a stream and passes it to Converter.ConvertMHTML() with save options for the target format. The complete C# example project is available in the Aspose.HTML for .NET GitHub repository.

How MHTML Conversion Works

  1. Open the MHTML file as a stream or provide another supported MHTML source.
  2. Create save options for the target format, such as PdfSaveOptions, ImageSaveOptions, DocSaveOptions, or XpsSaveOptions.
  3. Call Converter.ConvertMHTML() and pass the source stream, options, and output path.

The following example converts MHTML to JPG with ImageSaveOptions.

1// Convert MHTML to JPG in C#
2
3// Open an existing MHTML file for reading
4using FileStream stream = File.OpenRead(DataDir + "sample.mht");
5
6// Invoke the ConvertMHTML() method to convert MHTML to JPG
7Converter.ConvertMHTML(stream, new ImageSaveOptions(ImageFormat.Jpeg), Path.Combine(OutputDir, "convert-by-two-lines.jpg"));

MHTML Conversion Guides

Related Conversion Controls

Other Platforms

Try Online MHTML Conversion

                
            

Use the online MHTML Converter for quick archive conversion. Use Aspose.HTML for .NET when MHTML conversion must be automated in C#.