MHTML Converter – Aspose.HTML for Java

MHTML is a web page archive format that allows embedding multiple resources, such as images, CSS styles, audio, and video files, into a single file, typically with a .mht file extension. MHTML format allows a web page to be saved and sent as a single file, preserving its appearance and interactivity. It can be opened by most web browsers. But sometimes, you want to Convert MHTML to get the advantages of other formats.

Aspose.HTML for Java provides a wide range of MHTML conversions to popular formats, such as PDF, XPS, DOCX, JPG, PNG, BMP, TIFF, and GIF.

This section provides information on the list of supported MHTML conversions and how to perform them using convertMHTML() methods of the Converter class. It can be different scenarios, but any MHTML conversion can be made with a few required steps:

  1. Load an existing MHTML file. You can load MHTML from a file, stream, or URL.
  2. Create a SaveOptions object. You may customize the rendering process to get the desired result.
  3. Use one of the convertMHTML() methods and pass the required parameters to it.

Let’s consider the following code snippet that shows how to convert MHTML to PDF using our Java library:

1// Open an existing MHTML file for reading.
2java.io.FileInputStream fileInputStream = new java.io.FileInputStream($i("sample.mht"));
3
4// Invoke the ConvertMHTML() method to convert MHTML to PDF
5Converter.convertMHTML(fileInputStream, new PdfSaveOptions(), $o("convert-by-two-lines.pdf"));

Popular MHTML Conversions

You can download the complete examples and data files from GitHub.

Aspose.HTML provides a free online MHTML Converter that enables you to convert MHTML files to various popular formats. This tool can easily convert MHTML to PDF, XPS, DOCX, JPG, PNG, BMP, TIFF, and GIF. The conversion process is simple and fast. You don’t need any additional software. The best part is that it’s completely free!

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.