HTML, MHTML, EPUB and Markdown File Merger API

Combine multiple source files in C# and render them into one output document.

Merge HTML, MHTML, EPUB, and Markdown Files in C#

Aspose.HTML for .NET combines several same-type source files into one rendered document. For HTML, pass HTMLDocument objects to HtmlRenderer . For MHTML or MHT archives, pass streams to MhtmlRenderer ; for EPUB publications, use EpubRenderer . Markdown files first become HTMLDocument objects through Converter.ConvertMarkdown() and are then processed by HtmlRenderer. In every workflow, source order determines content order, while the output device determines the target format.


Choose a Merger Workflow

Source filesC# source representationRendererDetailed guide
HTMLHTMLDocumentHtmlRendererHTML Merger
MHTML or MHTStreamMhtmlRendererMHTML Merger
EPUBStreamEpubRendererEPUB Merger
Markdown or MDHTMLDocument returned by Converter.ConvertMarkdown()HtmlRendererMarkdown Merger

C# HTML Merger and Interactive Example

The hub example demonstrates the HTML workflow. Add local HTML files or URLs in the required order and select PDF, XPS, DOCX, TIFF, or MHTML. For renderer-based outputs, the C# panel updates the document declarations, output device, and extension to match the current selection. Run the configured merge online to inspect the result, or copy the generated code into a .NET project. See the HTML Merger guide for HTML-specific resource handling and limitations.

Choose an Output Device

  • Use PdfDevice to create a PDF for distribution, archiving, or printing.
  • Use XpsDevice to write the rendered sources to an XPS document.
  • Use DocDevice to create a DOCX document for compatible word processors.
  • Use ImageDevice with ImageRenderingOptions to generate TIFF or another supported raster format.

Each device has a corresponding rendering-options class for page size, margins, resolution, and other target-specific settings. See Rendering Devices in C# for the supported devices and constructors.

The interactive HTML merger also supports MHTML web archive output.


Get Started with Aspose.HTML for .NET API

Install Aspose.HTML for .NET from NuGet with the .NET CLI:

dotnet add package Aspose.HTML

You can also use the NuGet Package Manager UI or run Install-Package Aspose.HTML in the Package Manager Console. See the installation guide for setup details, or request a temporary license to evaluate the API without evaluation limitations.


Document Merger API FAQ

1. Does one renderer support every merger source format?

No. Use HtmlRenderer for HTMLDocument sources, MhtmlRenderer for MHTML or MHT streams, and EpubRenderer for EPUB streams. Markdown first becomes an HTMLDocument through Converter.ConvertMarkdown() and then uses HtmlRenderer.

2. Does merging create one editable source-format file?

No. The renderer sends several sources to one output device and creates a rendered PDF, XPS, DOCX, or raster result. It does not combine HTML DOM trees, MHTML MIME structures, EPUB packages, or Markdown text into a new source file.

3. Can different source formats be passed to one renderer call?

No. A renderer expects one source representation, such as HTMLDocument objects or archive streams. Use the workflow that matches the source collection, or normalize mixed inputs through a separate process before rendering.

4. What determines the order of content in the merged result?

The order of the sources passed to Render() determines their order in the output. Reorder the documents or streams before the call when the final PDF, XPS, DOCX, or TIFF needs a different sequence.

5. Can the merged output be written to a stream?

Yes. Output devices such as PdfDevice accept stream-based destinations, and ICreateStreamProvider supports workflows that require controlled creation and release of output streams. Keep the destination available until rendering finishes.

Explore More Aspose.HTML for .NET Features

Continue with focused tools and API guides for conversion, editing, code generation, and accessibility testing.