Aspose.HTML  for .NET

.NET API for working with real-world HTML

Class library to create, edit, extract data, merge and convert HTML pages to PDF, DOCX, XPS, Images and other formats.

  Download Free Trial

Aspose.HTML for .NET is an advanced HTML processing API to perform a wide range of management and manipulation tasks within cross-platform applications. API supports to generate, modify, extract data, convert and render HTML documents without any external software. Also, it supports popular file formats such as EPUB, MHTML, XML, SVG, and Markdown and rendering to PDF, DOCX, XPS and Image file formats.

Moreover, the HTML Document Object Model is integrated with embedded formats and specifications such as CSS, HTML Canvas, SVG, XPath and JavaScript out-of-the-box that extend the manipulation functional and rendering quality. You can see the full list of Aspose.HTML features in our documentation.

Using Aspose.HTML for .NET in your project allows you to perform the following tasks:

create or load HTML-based documents from a file, URL, string, or stream;
convert documents between popular formats;
create custom message handlers to do a specific task;
navigate HTML documents using XPath Query or CSS Selector;
edit HTML files by inserting new nodes, removing, or editing the content of existing nodes;
render documents with high quality;
extract data from the web, download a video or audio by its URL;
and more

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 data from HTML documents

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

Convert HTML to PDF, Image and Other Formats

API allows with just a few lines of code to implement HTML to PDF, HTML to Image or any other conversion for your .NET applications. The conversion process is simple and reliable, thus making Aspose.HTML for .NET API a perfect choice.

Convert HTML to PDF - C#

// Load an HTML file to be converted
using var document = new Aspose.Html.HTMLDocument("document.html");
// Convert HTML to PDF
Aspose.Html.Converters.Converter.ConvertHTML(document, new PdfSaveOptions(), "output.pdf");

You can also convert HTML, XHTML, MHTML, Markdown, EPUB, SVG into many other file formats including few listed below:

You can try online HTML Converter here.

Editing HTML Documents

Aspose.HTML for .NET allows you to create and edit HTML documents using a Document Object Model (DOM). The DOM is a programming interface for HTML documents that represents the document (as nodes and objects) as a node tree, where each node represents part of the document. Aspose.HTML for .NET API lets you connect to the page and can change the document structure, style, and content. You can modify the document by inserting new nodes and removing or editing existing nodes' content.

The .NET HTML API assists developers to read, modify, navigate and edit (X)HTML documents. Some file editing functions that the Aspose.HTML for .NET API can perform are the following:
- navigate HTML documents by using various methods, such as, element traversal, document traversal, XPath queries, and CSS selector queries,
- remove and replace HTML nodes,
- extract and edit CSS from HTML,
- configure a document sandbox and more.

Markdown Support

Markdown is a markup language with a plain-text-formatting syntax. Markdown is often used as a format for documentation and readme files since it allows writing in an easy-to-read and easy-to-write style. Aspose.HTML provides a powerful and flexible Markdown Converter that can convert in both directions from Markdown to HTML and from HTML to Markdown. Moreover, the converter API has a set of predefined rules, so you can convert HTML to Markdown using the authentic Markdown syntax, GitLab Flavored Markdown modification or even configure the rules for your needs.

Convert HTML to Markdown - C#

// Load an HTML file
using var document = new Aspose.Html.HTMLDocument("document.html");

// Convert HTML to Markdown using a set of features supported by GitLab Flavored Markdown
document.Save("", Aspose.Html.Saving.MarkdownSaveOptions.Git);

The reverse conversion is that simple!

Convert Markdown to HTML - C#

// Convert Markdown to HTML
Aspose.Html.Converters.Converter.ConvertMarkdown("", "output.html");

You can try online Markdown Converter here.

Electronic Books and Web Archives

The Electronic Books (EPUB) formats and Web Archive (MHTML) formats supported out-of-the-box. API offers high fidelity rendering EPUB and MHTML files to the supported output formats such as PDF, XPS and Image file formats.

Convert EPUB to PDF - C#

//  Convert EPUB to PDF
Aspose.Html.Converters.Converter.ConvertEPUB("document.epub", new Aspose.Html.Saving.PdfSaveOptions(), "output.pdf");

You can try online EPUB Converter here.

Convert MHTML to PDF - C#

//  Convert MHTML to PDF
Aspose.Html.Converters.Converter.ConvertMHTML("document.mht", new Aspose.Html.Saving.PdfSaveOptions(), "output.pdf");

You can try online MHTML Converter here.

Web Scraping

Web scraping, also well known as web harvesting, web data extraction or web crawling, is a technique to extract data from a website. Aspose.HTML doesn't support a Web Scraping module out-of-the-box. However, using Aspose.HTML API that is entirely based on W3C specification and supports XPath and CSS Selector queries you can easily inspect the content of any HTML document and create your own Web Scraping solution.

Simple Web Data Extraction - C#

// Create an instance of the HTML document with a website as a parameter
using var document = new Aspose.Html.HTMLDocument("");

// Get all anchor-elements
var elements = document.QuerySelectorAll("a");

// Dump the anchor-element data to the console
elements.Cast<HTMLAnchorElement>().ToList().ForEach(x =>
        System.Console.WriteLine("[Href]: " + x.Href);
        System.Console.WriteLine("[Content]: " + x.TextContent);

You can try online Data Scrapers Apps here.

Aspose.HTML offers free online Data Scrapers Apps that are a way to get data from websites. Our Apps are safe, work on any platform and do not require any software installation. Data Scrapers can be used for image extracting, getting keywords from a webpage, video downloading, etc. They are easy and clear to use, yet forceful and reliable.

Support and Learning Resources


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