NetPdf 0.0.1-phase0
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
<PackageReference Include="NetPdf" Version="0.0.1-phase0" />
<PackageVersion Include="NetPdf" Version="0.0.1-phase0" />
<PackageReference Include="NetPdf" />
paket add NetPdf --version 0.0.1-phase0
#r "nuget: NetPdf, 0.0.1-phase0"
#:package NetPdf@0.0.1-phase0
#addin nuget:?package=NetPdf&version=0.0.1-phase0&prerelease
#tool nuget:?package=NetPdf&version=0.0.1-phase0&prerelease
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-facewith 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,orphansposition: 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
Third-party attributions: THIRD-PARTY-NOTICES.md.
| Product | Versions 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. |
-
net10.0
- AngleSharp (>= 1.1.2)
- AngleSharp.Css (>= 1.0.0-beta.144)
- HarfBuzzSharp (>= 8.3.1.1)
- HarfBuzzSharp.NativeAssets.Linux (>= 8.3.1.1)
- HarfBuzzSharp.NativeAssets.macOS (>= 8.3.1.1)
- HarfBuzzSharp.NativeAssets.Win32 (>= 8.3.1.1)
- NetPdf.Css (>= 0.0.1-phase0)
- NetPdf.Layout (>= 0.0.1-phase0)
- NetPdf.Paginate (>= 0.0.1-phase0)
- NetPdf.Paint (>= 0.0.1-phase0)
- NetPdf.Pdf (>= 0.0.1-phase0)
- NetPdf.Svg (>= 0.0.1-phase0)
- NetPdf.Text (>= 0.0.1-phase0)
- SkiaSharp (>= 3.119.0)
- SkiaSharp.NativeAssets.macOS (>= 3.119.0)
- SkiaSharp.NativeAssets.Win32 (>= 3.119.0)
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.