How to Merge MHTML Files?
Aspose.HTML for .NET offers you tools to merge MHTML files online or programmatically via C#. Online MHTML Merger lets you merge multiple files into a single document in real-time right in your browser. If you want to use merging and conversion functionalities in your product or to merge MHTML programmatically, please download Aspose.HTML C# library, learn our documentation and consider the C# code examples. Powerful C# API allows you to merge MHTML files quickly and in high quality.
Online MHTML Merger
Test the quality of MHTML merging right in your browser! Please load files from the local file system, select the required output format and run the example! It’s fast, easy, secure, and completely free! You will immediately get the result as a separate file. So, quickly merge MHTML files and save the result to PDF, XPS, DOCX, or TIFF format online!
// Open existing MHTML files for reading using var stream1 = File.OpenRead(DataDir + "document1.mht"); using var stream2 = File.OpenRead(DataDir + "document2.mht"); // Create an instance of MHTML Renderer using var renderer = new Aspose.Html.Rendering.MhtmlRenderer(); // Create an instance of PDF device using var device = new Aspose.Html.Rendering.Pdf.PdfDevice("output-mht.pdf"); // Merge all MHTML documents into PDF renderer.Render(device, stream1, stream2);
Steps to Merge MHTML to PDF in C#
Aspose.HTML for .NET API provides the Renderer class for rendering and merging MHTML documents. Using the Renderer instances directly, you can send multiple files to the output rendering device at once. Aspose.HTML API provides the following implementation of renderers: HtmlRenderer, SvgRenderer, MhtmlRenderer and EpubRenderer, which are used to render HTML, SVG, MHTML and EPUB documents, respectively.
Please see the example above if you would like to merge MHTML files programmatically. You can merge documents with a few lines of C# code:
- Open an existing MHTML files.
- Create an instance of MHTML Renderer. Use the MhtmlRenderer() constructor.
- In this step, you can choose a rendering device. API provides the following implementations: PdfDevice, XpsDevice, DocDevice and ImageDevice, which are used to generate PDF, XPS, DOCX and Image file formats, respectively.
- If you want to merge MHTML to PDF, create a PDF device. Use the PdfDevice() constructor to initialise a new instance of the PdfDevice class.
- Call the Render() method to merge all MHTML documents into PDF.
- Copy C# code for MHTML files merging and use it in your project.
1. Why is this MHTML Merger useful?
MHTML Merger is a practical, powerful and fast tool to combine several MHTML files. You can quickly and easily merge MHTML documents into one and save the result in PDF, XPS, DOCX, and TIFF formats without any hassle!
2. How can I merge MHTML?
You can merge MHTML online or programmatically. To merge HTML online, please load files from your local file system or a URL, select the required output format from the list and run the example! You will immediately get the result. Moreover, you can copy C# code and use it on your own application for file merging.
3. Can I merge MHTML on Linux, Mac OS, iOS or Android?
You can use this free online MHTML Merger from a mobile device, tablet or computer. The interface of the Merger is very straightforward. Our tool is supported by all operating systems with a browser – Windows, Mac OS, Linux, Android, and iOS. There is no requirement to install any additional tool to support this tool running.
What is MHTML File Format
Files with MHTML extension represent a web page archive format that can be created by a number of different applications. The format is known as archive format because it saves the web HTML code and associated resources in a single file. These resources include anything linked to the webpage such as images, applets, animations, audio files and so on. MHTML files can be opened in a variety of applications such as Internet Explorer and Microsoft Word. The MHTML file format encodes the page contents similar to specifications defined in message/rfc822 which are plain text email related specifications. The actual specifications of the format are as detailed by RFC 2557.
How to Install Aspose.HTML for .NET library
You can use several ways to install the Aspose.HTML library for .NET on your system:
- Install a NuGet Package using the NuGet Package Manager GUI.
- Install a NuGet Package using the Package Manager Console. You may use the following command
PM> Install-Package Aspose.Html.
- Install Aspose.HTML for .NET through MSI.