Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

237 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Html2x

Html2x is a modern, cross-platform .NET 8 library for converting static HTML and CSS into PDF. The architecture separates parsing, style computation, layout, fragments, pagination, diagnostics, and rendering so each stage can be tested and extended independently.

Goals

  • Convert business-report HTML and CSS into deterministic PDF output.
  • Keep the implementation pure .NET, using AngleSharp for HTML/CSS parsing and SkiaSharp for PDF rendering.
  • Preserve clear module boundaries between public API, layout, diagnostics, and rendering.
  • Make unsupported input observable through diagnostics instead of silent behavior drift.

Documentation

The durable project map, module responsibilities, public API, supported scope, runtime behavior, and developer commands live in project documentation. Local agent workflow rules live in AGENTS.md.

Primary source documents:

For concepts, architecture, internals, extension paths, public API, supported HTML/CSS, diagnostics, and troubleshooting, start with the project documentation index.

Minimal Usage

using Html2x;
using Html2x.Options;

var converter = new HtmlConverter();

var result = await converter.ToPdfAsync(
    "<h1>Invoice</h1><p>Total: $42.00</p>",
    new HtmlConverterOptions
    {
        Fonts = new FontOptions
        {
            FontPath = @"C:\Projects\html2x\src\Tests\Html2x.TestConsole\fonts"
        }
    });

await File.WriteAllBytesAsync("invoice.pdf", result.PdfBytes);

With the default converter dependencies, HtmlConverterOptions.Fonts.FontPath must point to a font file or directory before layout begins. Advanced in-process callers may provide approved font or text adapter factories through HtmlConverterDependencies.

Scope

Supported scope includes static HTML/CSS, block and inline flow, basic tables, lists, images, pagination, borders, backgrounds, colors, fonts, diagnostics, and PDF rendering.

Out of scope includes JavaScript execution, dynamic DOM mutation, browser-compatible layout fidelity, full CSS grid/flex support, accessibility tagging, PDF forms, and browser engine embedding.

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages