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.
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 startedusing 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,TOCIandFormula(values 30 to 34; existing values unchanged), accepted byDisplayList.BeginTagand written byNote,Reference,TOC,TOCIandFormula. A formula keeps its alternative text.ArtifactType(None,Pagination,Layout,Page,Background),ArtifactSubtype(None,Header,Footer,Watermark), the overloadDisplayList.BeginTag(ItemId, ArtifactType, ArtifactSubtype)andDisplayItem.ArtifactType/ArtifactSubtype. … Output without a kind is unchanged, and the display-list format version is unchanged.docs/display-list.mdstates whatLocalBounds,RootBoundsandLayerBoundshold 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.
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();
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
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.
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 worksThe packages
- RecursiveAI.OneRender
The engine: styles, layout, paged media, paint to a display list, hit testing, events, focus, forms and animations. Depends on onehtml and onefont. 1.4.0.
- .Image
RecursiveAI.OneRender.turns the display list into pixels:Image HtmlRender.ToImage, through oneimage. 1.4.0. - .Pdf
RecursiveAI.OneRender.writes a tagged PDF:Pdf HtmlPdf.ToPdf, through onepdf. 1.4.0. - .Razor
RecursiveAI.OneRender.renders a Razor component to a PDF or an image in one call. 1.4.0.Razor - .Accessibility
RecursiveAI.OneRender.produces rendered page facts in onehtml’sAccessibility RenderedFactsshape. 1.4.0. - .Fonts
RecursiveAI.OneRender.bundles Liberation Sans, Serif and Mono, Carlito and Caladea, which also answer to Arial, Times New Roman, Courier New, Calibri and Cambria, plus a fallback face for symbols such as ★ and ✓. 1.4.0.Fonts - .Fonts.Cjk
RecursiveAI.OneRender.adds Noto Sans CJK for Chinese, Japanese and Korean. 1.4.0.Fonts. Cjk - .Fonts.Emoji
RecursiveAI.OneRender.adds Noto Color Emoji. 1.4.0.Fonts. Emoji - .Fonts.Noto.*
29 script packs, from Arabic, Devanagari and Hebrew to Thai, Tibetan and Math. All 29 on NuGet. 1.4.0.
- .NET
.NET 10. NativeAOT, trimming and WebAssembly are supported. Every package shares one version. MIT or Apache-2.0; the font packages add the SIL Open Font License.