How to Merge HTML Files Using C#
In order to merge HTML, MHTML, EPUB and MD files, we will use
Aspose.HTML for.NET API
which is a feature-rich, powerful and easy-to-use document manipulation API for the C# platform. You can choose a kind of Merger for different source files such as HTML, MHTML, EPUB, or Markdown, and save the files merging result to one of the following output formats: PDF, MHTML, XPS, TIFF or DOCX.
Aspose.HTML for.NET API makes the merging process easier for developers: loads files using HTMLDocument class; creates an instance of HTML Renderer and a required output device; uses the Render() method to merge all HTML documents.
Online HTML Merger
You can merge HTML files with Aspose.HTML for .NET API in real-time. HTML Merger lets you combine multiple HTML documents into a single file. You can select one of the following output formats: PDF, MHTML, XPS, TIFF or DOCX. Load files, merge and get results in a few seconds!
// Load HTML files using var document1 = new Aspose.Html.HTMLDocument("first-document.html"); using var document2 = new Aspose.Html.HTMLDocument("second-document.html"); // Create an instance of HTML Renderer using var renderer = new Aspose.Html.Rendering.HtmlRenderer(); // Create an instance of PDF device using var device = new Aspose.Html.Rendering.Pdf.PdfDevice("output.pdf"); // Merge all HTML documents into PDF renderer.Render(device, document1, document2);
Installing Aspose.HTML for .NET library
Aspose.HTML is an advanced web scraping and HTML parsing library. This library supports parsing of HTML5, CSS3, SVG and HTML Canvas to construct a Document Object Model (DOM) based on the WHATWG DOM Standard. You can use several ways to install the Aspose.HTML library for .NET on your system:
- Using the NuGet Package Manager GUI.
- Using the Package Manager Console.
- Installing Aspose.HTML for .NET through MSI.
Use the Aspose.HTML C# library to convert, merge, edit HTML documents, extract data from the web, and more! For more details about C# library installation, please refer to Aspose.HTML Documentation.
Other Supported Aspose.HTML for .NET API Features
Using Aspose.HTML, an advanced web scraping and HTML parsing library, you can create, edit, navigate through nodes, extract data, merge and convert HTML, XHTML, MD, EPUB, and MHTML files to PDF, XPS, DOCX, Images and other formats.