.NET APIs to Manipulate HTML Files

Create, Read and Edit HTML documents including CSS styles as well as Render to PDF & Raster Image formats.

  Download Free Trial
Aspose.HTML for .NET

Aspose.HTML for .NET


Aspose.HTML for .NET is an advanced API to create and manipulate HTML documents within .NET applications. Developers can insert, remove, replace nodes, extract CSS styles, navigate through document either by NodeIterator, TreeWalker that is provided by traversal specifications, XPath or CSS selector queries. Furthermore, It allows DOM manipulation via JavaScript through its own scripting.

Aspose.HTML for .NET provides the capabilities to load HTML file and render the output in PDF, XPS and raster image formats. Moreover, API supports to encrypt the document and can specify the page setup information for resultant output while converting the output as PDF file as well as can also specify the compression value for JPEG images inside the output document.


Advanced .NET HTML Manipulation API Features



Create HTML pages from Scratch


Load existing HTML from file, stream or URL


Implement W3C specifications


Implement templates using template merger


Fill the template with various data sources


Render HTML Canvas 2D to PDF


Add, replace or remove nodes


Extract CSS styling information


Load EPUB and MHTML file formats


Render HTML to raster image formats


Render multiple documents at once


Implement Markdown to HTML converter


Apply header and footer during HTML to PDF

HTML to PDF & XPS 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 hfile = 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"), hfile);
    renderer.Render(new Aspose.Html.Rendering.Xps.XpsDevice(dir + "output.xps"), hfile);

Convert HTML to Image

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.

Navigate HTML Nodes

Aspose.HTML for .NET enables you to navigate through the document either by elements, XPath or CSS selector queries and extract, insert, remove, replace 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 documents, that is; the CSS styles in some cases are dependent on screen size. .NET HTML library allows configuring 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: