Recursive AI
LibraryC#Available

onerender

An HTML and CSS rendering engine for .NET, written in C# from the specifications. It renders HTML to pixels or a tagged PDF, with no browser, no network and no clock.

dotnet add package RecursiveAI.OneRender.Pdf

A quick look

One call each for a PDF and a PNG. The PDF is tagged from the HTML, and the text is set in bundled fonts, so the output is the same on every machine.

Getting started
Program.csC#
using OneRender.Image;
using OneRender.Pdf;
string html = "<h1>Invoice INV-1042</h1><p>Rendered without a browser.</p>";
File.WriteAllBytes("invoice.pdf", HtmlPdf.ToPdf(html));
var options = new HtmlRenderOptions { Width = 600, Height = 200 };
RgbaImage image = HtmlRender.ToImage(html, options);
File.WriteAllBytes("invoice.png", image.ToPng());

New in 1.4

Display lists built by hand can tag contents, notes and formulas, and say what kind of artifact a header or footer is. From the 1.4.0 changelog:

  • TagRole.Note, Reference, TOC, TOCI and Formula (values 30 to 34; existing values unchanged), accepted by DisplayList.BeginTag and written by .Pdf as the structure types Note, Reference, TOC, TOCI and Formula. A formula keeps its alternative text.
  • ArtifactType (None, Pagination, Layout, Page, Background), ArtifactSubtype (None, Header, Footer, Watermark), the overload DisplayList.BeginTag(ItemId, ArtifactType, ArtifactSubtype) and DisplayItem.ArtifactType / ArtifactSubtype. … Output without a kind is unchanged, and the display-list format version is unchanged.
  • docs/display-list.md states what LocalBounds, RootBounds and LayerBounds hold for each push item (a clip carries its shape’s bounds; the other pushes have none).

The HTML painter never emits the new roles: they are for producers that paint their own display list.

Program.csOneRender 1.4.0
page.BeginTag(Id(), ArtifactType.Pagination, ArtifactSubtype.Header);
Text(page, "Harbor Street Books · Annual report 2026", 9, 48, 40);
page.EndTag();
 
page.BeginTag(Id(), TagRole.TOC);
page.BeginTag(Id(), TagRole.TOCI);
Text(page, "1  Sales ........ 2", 12, 48, 140);
page.EndTag();
// … two more entries, then EndTag()
 
page.BeginTag(Id(), TagRole.Formula, "R equals n times p");
Text(page, "R = n × p", 12, 110, 230);
page.EndTag();
Structure tree, read backPDF/UA-1
Document
  H1
  TOC
    TOCI
    TOCI
    TOCI
  P
    Formula  Alt: R equals n times p
    Reference
  Note
/Artifact <</Type /Pagination/Subtype /Header>> BDC
/Artifact <</Type /Pagination/Subtype /Footer>> BDC
What it does

What it does

Lays out real CSS

Block and inline layout, floats, positioning, flexbox, grid with subgrid, tables, multi-column, and bidirectional text shaped by onefont.

Tagged PDFs from HTML

Headings, lists, tables and alt text become the PDF’s structure, with PDF/UA-1 and PDF/A-2a one option away. @page, margin boxes, page numbers and table headers that repeat on every page work.

Razor in one call

Render a Razor component to a PDF or an image inside ASP.NET Core, with style sheets, images and fonts served from wwwroot.

Interactive UIs and games

Hit testing, DOM-standard events, focus, scrolling, form controls with text editing, light and dark schemes, and CSS animations on your own clock. Change text, classes and attributes from C# as the game runs. Steady frames allocate nothing.

Accessibility checks without a browser

Lays a page out and hands onehtml’s checker the rendered facts it needs for contrast and target size.

Nothing runs that you didn’t pass in

No JavaScript, no network, no processes and no unsafe code. Your code supplies every style sheet, image and font, and limits are checked before the work they guard.

How it’s checked

Compared with Chrome, element by element

Layout is compared with Chrome for Testing 156 on the same font files. On six document templates, 99.967% of the geometry is within tolerance at both 1280 × 800 and 390 × 844. Web Platform Tests gate each CSS module, and tagged PDFs are validated against PDF/UA-1 with veraPDF.

How the comparison works

The packages

Go further