Skip to content

Latest commit

 

History

639 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aspose.HTML for .NET — Agentic Examples

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.

About Aspose.HTML for .NET

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

Install

dotnet add package Aspose.HTML

Or via NuGet Package Manager:

Install-Package Aspose.HTML

Requires .NET SDK 10.0 or later.

Statistics

Metric Value
Total Examples 1807
Categories 18
Overall Pass Rate 100.0%
Package Version Aspose.HTML 26.9
Last Updated 2026-10-02

Repository Structure

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/

Categories

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

Frequently Asked Questions

How do I convert HTML to PDF in Aspose.HTML for .NET?

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.

How do I extract images from an HTML page or website?

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.

How do I convert HTML to Markdown?

Use Converter.ConvertHTML(document, new MarkdownSaveOptions(), outputPath). See markdown-converter and markdown-processing.

How do I query the DOM with XPath in Aspose.HTML?

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.

How do I render HTML to an image (PNG/JPEG)?

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.

How do I extract SVG content from an HTML page?

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.

Why do I get CS0535 on my ICreateStreamProvider implementation?

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.

Can I convert HTML to EPUB?

Yes — Converter.ConvertHTML accepts EpubSaveOptions for e-book output. See epub-converter.

Can these examples be used by AI coding agents like Claude, Copilot, or Cursor?

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.

Do I need an Aspose.HTML license to run these examples?

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.

How to Use

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 run

Example

Convert 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);
            }
        }
    }
}

For AI Coding Agents

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.

Prerequisites

  • .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.

Agentic .NET Ecosystem

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

Related Resources

Official Documentation

Downloads & Packages

Community & Support

Licensing & Purchase

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

About

Agentic, build-validated C# examples for Aspose.HTML for .NET covering HTML conversion, rendering, DOM editing, templates, document loading, and data extraction.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages