.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 HTML manipulation API to create and manipulate HTML documents within .NET applications. Developers can insert, remove, replace HTML nodes, extract CSS styles, navigate through HTML document either by NodeIterator, TreeWalker that is provided by traversal specifications, XPath or CSS selector queries. Furthermore, It allows HTML 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 HTML specifications


Implement html templates using template merger


Fill template with various data sources


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


Implement Markdown to HTML converter


Apply header and footer during HTML to PDF

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.

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: