.NET APIs to manipulate HTML files on the fly

Create, read, edit HTML documents including CSS styles and render to PDF & raster image formats.

  Download Free Trial
Aspose.HTML for .NET

Aspose.HTML for .NET


Aspose.HTML for .NET is an advanced HTML manipulation API that can be used with .NET Framework and .NET Core to perform a wide range of HTML manipulation tasks directly within your own applications.

Aspose.HTML for .NET allows to create, load, edit or convert (X)HTML documents without requiring additional software or tools. Along with manipulation functions, the API also provides high fidelity rendering engine for fixed-layout formats such as PDF & XPS, and a number of raster image formats.


Advanced .NET HTML Manipulation API Features



Create HTML pages from Scratch


Load existing HTML from file, stream or URL


Implement W3C HTML specifications


Render HTML Canvas 2D to PDF


Add, replace or remove HTML nodes


Extract CSS styling information


Load EPUB and MHTML file formats


Render HTML to raster image formats


Render multiple documents at once

HTML to Fixed-Layout Format Conversion

Aspose.HTML for .NET provides the ability to render HTML in PDF and XPS file formats. The conversion process is highly customizable, allowing you to configure PageSetup aspects for the resultant fixed-layout formats, that is; you can specify the page numbers to be rendered, tweak the resultant page size or set the JPEG compression for the embedded images.

Save HTML in different formats - C#

// load the file to be rendered
var html = new Aspose.Html.HTMLDocument(dir + "template.html");
// render to PDF & XPS
using (var renderer = new Aspose.Html.Rendering.HtmlRenderer())
    renderer.Render(new Aspose.Html.Rendering.Pdf.PdfDevice(dir + "output.pdf"), html);
    renderer.Render(new Aspose.Html.Rendering.Xps.XpsDevice(dir + "output.xps"), html);

Render HTML to Raster Image Formats

Aspose.HTML for .NET offers the high fidelity rendering engine at its core which can convert HTML pages to raster image formats including TIFF, BMP, PNG & JPEG without requiring any additional software or tool.

Load & Manipulate ePub and MHTML Files

Aspose.HTML for .NET is capable of loading ePub and MHTML files to perform various operations including the conversion to fixed-layout and raster image formats.

Navigate HTML Nodes

Aspose.HTML for .NET enables you to navigate through the HTML document either by elements, XPath or CSS selector queries, and extract, insert, remove, replace HTML nodes on the go.

Extract all nodes of type anchor - C#

// create an instance of HTMLDocument & load HTML from URL
using (var document = new Aspose.Html.HTMLDocument("https://www.aspose.com"))
    // get all nodes of type anchor
    var nodelist = document.DocumentElement.QuerySelectorAll("a");
    // display anchor text & href values for all nodes
    foreach (Aspose.Html.HTMLAnchorElement node in nodelist)
        Console.WriteLine("Text: " + node.TextContent + " Href: " + node.Href);

Configure Sandbox

The HTML API enables you to configure a document sandbox that affects the processing of HTML documents, that is; the CSS styles in some cases are dependent on screen size. Aspose.HTML for .NET allows to configure the environment independent of the execution machine.


Support and Learning Resources


Aspose.HTML offers individual HTML processing APIs for other popular development environments as listed below: