NetPdf 0.0.1-phase0

This is a prerelease version of NetPdf.
There is a newer version of this package available.
See the version list below for details.

Requires NuGet 5.0.0 or higher.

dotnet add package NetPdf --version 0.0.1-phase0
                    
NuGet\Install-Package NetPdf -Version 0.0.1-phase0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetPdf" Version="0.0.1-phase0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetPdf" Version="0.0.1-phase0" />
                    
Directory.Packages.props
<PackageReference Include="NetPdf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetPdf --version 0.0.1-phase0
                    
#r "nuget: NetPdf, 0.0.1-phase0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetPdf@0.0.1-phase0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetPdf&version=0.0.1-phase0&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NetPdf&version=0.0.1-phase0&prerelease
                    
Install as a Cake Tool

NetPdf

A pure C# / .NET HTML+CSS-to-PDF rendering engine. Free, open-source, Apache-2.0.

NetPdf is a true paged-media renderer written from scratch in managed code. It does not wrap a browser, not shell out to native binaries, not depend on revenue-capped or copyleft libraries. It converts a single HTML+CSS string into a deterministic PDF byte stream optimized for documents — invoices, statements, contracts, reports, certificates, catalogs.

Status: Phase 0 — architecture lock. Public API surface defined; internals under active construction. Not yet functional. First alpha (0.1.0-alpha) targets programmatic PDF construction; first useful release (0.7.0-beta) targets static-document rendering.

Why another HTML-to-PDF library?

Every existing free option for .NET fails one or more critical criteria:

Library Issue
HtmlRenderer.PdfSharp CSS 2 only, abandoned
DinkToPdf / wkhtmltopdf Abandoned, unpatched CVE-2022-35583, obsolete WebKit
QuestPDF MIT under $1M revenue, commercial above
SixLabors.ImageSharp / .Fonts Same revenue clause
iText pdfHTML AGPL or commercial
Syncfusion / IronPDF / Aspose / Spire Commercial
PuppeteerSharp / PlaywrightSharp Heavy; embeds Chromium

NetPdf fills the gap: truly free, truly forever, truly open source.

Direction

Closer to Prince, WeasyPrint, OpenHTMLtoPDF than to Playwright/Puppeteer/wkhtmltopdf. Layout-engine first, paint-engine second, PDF byte-writer third — all built from scratch using public W3C / Unicode / ISO specifications under a clean-room policy.

Public API (frozen for v1)

using NetPdf;

// One-liner
var pdf = HtmlPdf.Convert("<h1>Invoice #1234</h1><p>Hello world.</p>");
File.WriteAllBytes("out.pdf", pdf);

// With options
var pdf = HtmlPdf.Convert(html, new HtmlPdfOptions
{
    BaseUri = new Uri("file:///app/templates/"),
    PageSize = PageSize.Letter,
    PrintBackgrounds = true,
});

// Async streaming
await using var fs = File.Create("report.pdf");
await HtmlPdf.ConvertAsync(html, fs, new HtmlPdfOptions { PreferCssPageSize = true });

// Diagnostic mode
var result = HtmlPdf.ConvertDetailed(html);
foreach (var d in result.Warnings) Console.WriteLine($"{d.Code}: {d.Message}");

See docs/compatibility-matrix.md for the supported / not-supported feature list. See docs/diagnostics-codes.md for the stable diagnostic code registry. See docs/phases/ for per-phase execution guides — what to build, in what order, with exit criteria.

v1 capability summary

Supported:

  • Block & inline layout, lists, tables (with <thead>/<tfoot> repetition across pages)
  • Web fonts (@font-face with TTF/OTF/WOFF/WOFF2), font fallback, OpenType shaping, ligatures, kerning, RTL, CJK
  • Images (JPEG passthrough, PNG/Flate, WebP/AVIF via Skia decode)
  • Static SVG (shapes, paths, gradients, transforms, text)
  • Custom properties (--*), var(), calc()/min()/max()/clamp()
  • @media print, @page (size, margins, margin boxes), break-*, widows, orphans
  • position: absolute/fixed (fixed repeats per page)
  • 2D transforms, opacity, gradients, box/text shadows
  • Flexbox L1, CSS Grid Level 1
  • Filters via subtree raster fallback (blur, drop-shadow, brightness, contrast, etc.)

Not supported in v1 (parsed without error; emits structured diagnostics):

  • JavaScript, canvas, <video>, <audio>, service workers
  • 3D transforms, sticky positioning, animations/transitions
  • CSS Grid Level 2 (subgrid), container queries, :has() rendering, anchor positioning

Post-v1 roadmap: tagged PDF (PDF/UA-1) → PDF/A-3u → Grid L2 → container queries → :has() → anchor positioning.

Performance gates (enforced in CI)

  • 3-page invoice ≤ 200 ms p50 on commodity desktop.
  • 20-page report ≤ 1.5 s p50.
  • Linear memory growth with page count.
  • No process spawning at render time.
  • Native AOT compatible.
  • Deterministic output: identical input → identical bytes.

License

Apache-2.0.

Third-party attributions: THIRD-PARTY-NOTICES.md.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on NetPdf:

Package Downloads
NetPdf.Languages.Arabic

Optional Arabic-script language pack for NetPdf. Registers Arabic (ar), Persian/Farsi (fa), and Urdu (ur) with NetPdf's public HyphenationRegistry as explicit NO-hyphenation languages — Arabic-script text is not soft-hyphenated (justification uses kashida/tatweel elongation, not hyphens) — so hyphens:auto inserts no hyphens for those languages instead of falling back to the English hyphenator. Call ArabicHyphenation.Register at startup; a module initializer also drives it on assembly load.

NetPdf.Languages.Indic

Optional Indic-script language pack for NetPdf. Registers the major Indic languages (Hindi, Sanskrit, Marathi, Nepali, Bengali, Assamese, Panjabi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) with NetPdf's public HyphenationRegistry so layout can hyphenate a block by its effective lang. Indic scripts DO hyphenate, but this build ships NO pattern data yet — the CTAN hyph-utf8 (LPPL) pattern sets are vendored by the maintainer; until then hyphens:auto produces no breaks for these languages (conservative — never the wrong English hyphenation). Call IndicHyphenation.Register at startup; a module initializer also drives it on assembly load.

NetPdf.Languages.Cjk

Optional CJK (Chinese/Japanese/Korean) language pack for NetPdf. Registers zh/ja/ko with NetPdf's public HyphenationRegistry as explicit NO-hyphenation languages (CJK does not use Liang/soft hyphenation — line breaking is per-character, handled by NetPdf's UAX #14 breaker), so hyphens:auto correctly inserts no hyphens for CJK instead of falling back to the English hyphenator. Richer CJK line-break tailoring (kinsoku) is a follow-up. Call CjkHyphenation.Register at startup; a module initializer also drives it on assembly load.

NetPdf.Languages.European

Optional European-language hyphenation pack for NetPdf. Registers a German + French starter set of TeX/Liang hyphenation patterns into NetPdf's public HyphenationRegistry (call EuropeanHyphenation.Register at startup; a module initializer also drives it on assembly load). NetPdf's layout hyphenates a block by its effective HTML lang, so a lang-tagged document (e.g. <html lang="de">) uses these patterns when the pack is loaded. The remaining European languages and the full CTAN pattern data are follow-ups.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 1,747 10/1/2026
1.1.1 365 9/30/2026
1.1.0 326 9/30/2026
1.0.2 4,121 7/10/2026
1.0.1 356 7/9/2026
1.0.0 761 7/9/2026
0.0.1-phase0 87 5/1/2026