Agentic, build-validated C# code examples for Aspose.HTML for .NET covering HTML conversion, DOM manipulation, and web content extraction. Every example compiles and runs successfully. Includes agents.md guides optimized for AI coding agents.
Aspose.HTML for .NET is an HTML document manipulation and conversion library for .NET applications. It provides a full DOM implementation and lets developers parse, edit, render, and convert HTML documents programmatically without a browser.
Key capabilities:
- Convert HTML to PDF, image (PNG/JPEG), XPS, Markdown, and EPUB
- Parse and query the DOM with a standards-based API, including XPath and traversal (
NodeIterator/TreeWalker) - Render HTML with CSS, including HTML5 Canvas content, to raster or vector output
- Load HTML from local files, in-memory strings, or fetch it live from a remote URL
- Extract embedded assets — images, SVG, stylesheets — from an HTML document or a web page
- Observe and react to DOM mutations programmatically
- Produce custom in-memory or streamed output via
ICreateStreamProvider
dotnet add package Aspose.HTMLOr via NuGet Package Manager:
Install-Package Aspose.HTML
Requires .NET SDK 10.0 or later.
| Metric | Value |
|---|---|
| Total Examples | 1807 |
| Categories | 18 |
| Overall Pass Rate | 100.0% |
| Package Version | Aspose.HTML 26.9 |
| Last Updated | 2026-10-02 |
agents.md
README.md
+-- advanced-html-editing/
+-- data-extraction/
+-- epub-converter/
+-- extract-images-from-website/
+-- extract-svg-from-website/
+-- fine-tuning-converters/
+-- html-converter/
+-- html-navigation/
+-- markdown-converter/
+-- markdown-processing/
+-- message-handlers/
+-- mhtml-converter/
+-- save-file-from-url/
+-- svg-converter/
+-- web-accessibility/
+-- website-to-html/
+-- working-with-html-documents/
+-- working-with-html-templates/
| Category | Examples | Pass Rate | Details |
|---|---|---|---|
| Advanced Html Editing | 37 | 100.0% | agents.md |
| Data Extraction | 81 | 100.0% | agents.md |
| Epub Converter | 143 | 100.0% | agents.md |
| Extract Images From Website | 37 | 100.0% | agents.md |
| Extract Svg From Website | 30 | 100.0% | agents.md |
| Fine Tuning Converters | 121 | 100.0% | agents.md |
| Html Converter | 198 | 100.0% | agents.md |
| Html Navigation | 120 | 100.0% | agents.md |
| Markdown Converter | 79 | 100.0% | agents.md |
| Markdown Processing | 120 | 100.0% | agents.md |
| Message Handlers | 98 | 100.0% | agents.md |
| Mhtml Converter | 107 | 100.0% | agents.md |
| Save File From Url | 28 | 100.0% | agents.md |
| Svg Converter | 105 | 100.0% | agents.md |
| Web Accessibility | 96 | 100.0% | agents.md |
| Website to Html | 30 | 100.0% | agents.md |
| Working With Html Documents | 332 | 100.0% | agents.md |
| Working With Html Templates | 45 | 100.0% | agents.md |
Load the document with HTMLDocument, then call Converter.ConvertHTML(document, new PdfSaveOptions(), outputPath), or use the Rendering.Pdf namespace's PdfDevice directly when you need lower-level control (custom page size/margins via PdfRenderingOptions). See html-converter and fine-tuning-converters.
Load the page (from a file, string, or a live URL via HttpClient), locate <img> elements or CSS background images through the DOM, and save each one via ImageSaveOptions or by reading the underlying resource stream directly. See extract-images-from-website.
Use Converter.ConvertHTML(document, new MarkdownSaveOptions(), outputPath). See markdown-converter and markdown-processing.
Use HTMLDocument.CreateNodeIterator / Evaluate from the Aspose.Html.Dom.XPath namespace against an HTMLDocument, which implements the standard DOM Document interface. See data-extraction and html-navigation.
Convert with Converter.ConvertHTML(document, new ImageSaveOptions(ImageFormat.Png), outputPath), or use ICreateStreamProvider when you need the bytes in memory rather than on disk. See html-converter.
Locate <svg> elements via the DOM (Aspose.Html.Dom.Svg), then save each SVGDocument directly or via a resource handler for embedded SVG assets. See extract-svg-from-website.
The interface requires exactly four members: two GetStream overloads, ReleaseStream, and Dispose. An incomplete implementation fails to compile — see the Boundaries section in AGENTS.md.
Yes — Converter.ConvertHTML accepts EpubSaveOptions for e-book output. See epub-converter.
Yes — the repository ships an AGENTS.md at root and a lowercase agents.md in each category folder, plus .well-known/agent.json, llm.txt, and a machine-readable index.json. Point your agent at the repo's raw URLs and it can browse examples programmatically.
The library runs in evaluation mode without a license (with some output restrictions). For production use, apply a license via new License().SetLicense(path). Purchase / trial options: https://purchase.aspose.com/buy.
Each example is a self-contained C# file. Clone the repository and run any example directly:
git clone https://github.com/aspose-html/agentic-net-examples.git
cd agentic-net-examples
# Navigate to a category
cd html-converter
# Create a console project, add the package, and run an example
dotnet new console -o ExampleRunner
cd ExampleRunner
dotnet add package Aspose.HTML
# Copy any .cs file from the category as Program.cs and run
cp ../convert-html-to-pdf.cs Program.cs
dotnet runConvert an HTML file to PDF:
using System;
using Aspose.Html;
using Aspose.Html.Converters;
using Aspose.Html.Saving;
class Program
{
static void Main()
{
using (var document = new HTMLDocument("input.html"))
{
Converter.ConvertHTML(document, new PdfSaveOptions(), "output.pdf");
Console.WriteLine("Saved output.pdf");
}
}
}Query the DOM with XPath:
using System;
using Aspose.Html;
using Aspose.Html.Dom.XPath;
class Program
{
static void Main()
{
using (var document = new HTMLDocument("input.html"))
{
var result = document.Evaluate("//a/@href", document, null, XPathResultType.Any, null);
XPathNavigator? node;
while ((node = result.IterateNext()) != null)
{
Console.WriteLine(node.Value);
}
}
}
}This repository includes an AGENTS.md file at the root and a lowercase agents.md in each category folder. These files provide AI coding agents with:
- Required namespaces and using directives for each category
- Correct API property paths and patterns
- Common pitfalls and prohibited patterns
- Example code fragments for key operations
If you are an AI coding agent generating Aspose.HTML for .NET code, read the relevant agents.md before generating examples to avoid common API mistakes.
- .NET SDK 10.0 or later
- Aspose.HTML for .NET 26.9 (via NuGet)
A valid Aspose license is required for production use. For evaluation, examples run without a license but output may include evaluation notices.
Other Aspose products with agentic, build-validated example repositories:
| Product | Repository | Focus |
|---|---|---|
| Aspose.Words for .NET | aspose-words/agentic-net-examples | Word processing, DOCX, mail merge |
| Aspose.Cells for .NET | aspose-cells/agentic-net-examples | Spreadsheets, Excel, charts |
| Aspose.BarCode for .NET | aspose-barcode/agentic-net-examples | Barcode generation and recognition |
| Aspose.Imaging for .NET | aspose-imaging/agentic-net-examples | Image conversion, manipulation |
| Aspose.Slides for .NET | aspose-slides/agentic-net-examples | Presentations, PowerPoint |
| Aspose.Email for .NET | aspose-email/agentic-net-examples | Email, calendars, messaging |
| Aspose.PDF for .NET | aspose-pdf/agentic-net-examples | PDF creation, conversion and manipulation |
- Aspose.HTML for .NET Documentation — Guides, tutorials, and feature overviews
- API Reference — Complete class/method reference
- Release Notes — Version history and changelogs
- NuGet Package — Install via
dotnet add package Aspose.HTML - Direct Downloads — MSI/ZIP installers and DLLs
- Aspose.HTML Forum — Community Q&A and official support
- Aspose Blog - HTML — Tutorials, tips, and product updates
- GitHub Issues — Bug reports and feature requests
- Purchase — Commercial license options
- Temporary License — Full-feature evaluation license
All examples use Aspose.HTML for .NET and require a valid license for production use. See licensing options.
This repository is maintained by automated code generation. For AI-friendly guidance, see AGENTS.md. Last updated: 2026-10-02
Updated: 2026-10-02 | Examples: 1807 | Categories: 18 | Package: Aspose.HTML 26.9