H2Pdf 0.0.1
dotnet add package H2Pdf --version 0.0.1
NuGet\Install-Package H2Pdf -Version 0.0.1
<PackageReference Include="H2Pdf" Version="0.0.1" />
<PackageVersion Include="H2Pdf" Version="0.0.1" />
<PackageReference Include="H2Pdf" />
paket add H2Pdf --version 0.0.1
#r "nuget: H2Pdf, 0.0.1"
#:package H2Pdf@0.0.1
#addin nuget:?package=H2Pdf&version=0.0.1
#tool nuget:?package=H2Pdf&version=0.0.1
H2Pdf
๐ Generate production-ready PDFs using Razor components and C# in minutes.
H2Pdf bridges modern .NET UI development and deterministic PDF generation. Build PDFs with familiar .razor components, strongly typed C#, and dependency injection.
โจ Features
- Razor components as PDF templates
- Fluent PDF document model API
- Optional HTML-to-PDF pipeline (
HtmlPdfRenderer) - ASP.NET Core dependency injection integration
- Cross-platform rendering (Windows, Linux, macOS)
๐ Quick Start (30 seconds)
Requirements: .NET 10 SDK
git clone https://github.com/evilz/H2Pdf.git
cd H2Pdf
dotnet build
cd samples/H2Pdf.Sample
dotnet run
Generated files:
sample-output.pdfinvoice-sample.pdf
๐ฆ Installation
Install via NuGet:
dotnet add package H2Pdf
Or clone from source:
git clone https://github.com/evilz/H2Pdf.git
cd H2Pdf
dotnet build
๐ Usage
var services = new ServiceCollection();
services.AddLogging();
services.AddH2Pdf();
var provider = services.BuildServiceProvider();
var renderer = provider.GetRequiredService<PdfRenderer>();
var parameters = new Dictionary<string, object?>
{
["Name"] = "Developer",
["Message"] = "This PDF was generated from a Razor component."
};
var document = await renderer.RenderToPdfAsync<HelloWorld>(parameters);
renderer.SaveToPdf(document, "output.pdf");
See samples/ and examples/ for complete usage patterns.
โก Benchmark
Compare Playwright HTML-to-PDF with H2Pdf HTML-to-MigraDoc rendering:
dotnet build benchmarks/H2Pdf.Benchmarks
pwsh benchmarks/H2Pdf.Benchmarks/bin/Debug/net10.0/playwright.ps1 install chromium
dotnet run -c Release --project benchmarks/H2Pdf.Benchmarks
Environment
- BenchmarkDotNet v0.14.0
- .NET 10.0.2 (RyuJIT, AVX2)
- Windows 11 x64
- GC: Concurrent Workstation
๐งช Benchmarked Pipelines
Playwright (Chromium)
- HTML rendered in headless Chromium
- PDF generated via
Page.PdfAsync()
MigraDoc (via HtmlPdfRenderer)
- HTML โ MigraDoc DOM
- MigraDoc โ PDF via
PdfDocumentRenderer
๐ Example output (single run)
| Method | Mean | StdDev | Gen0 | Gen1 | Allocated |
|---|---|---|---|---|---|
| PlaywrightHtmlToPdfAsync | 9.231 ms | 0.196 ms | 15.63 | - | 188 KB |
| MigraDoc_HtmlToPdf | 4.684 ms | 0.014 ms | 312.50 | 109.38 | 2.68 MB |
These numbers are an example from one environment and one HTML payload.
Results will vary by machine, OS, runtime version, browser version, and template complexity.
โฑ Latency per PDF (example)
- MigraDoc: ~4.68 ms
- Playwright: ~9.23 ms
๐ Stability (Jitter, example)
| Pipeline | StdDev |
|---|---|
| MigraDoc | 0.014 ms |
| Playwright | 0.196 ms |
๐ง Memory Behavior (example)
| Pipeline | Allocated per PDF |
|---|---|
| Playwright | ~188 KB |
| MigraDoc | ~2.68 MB |
GC activity:
- MigraDoc โ Triggers Gen0 + Gen1
- Playwright โ Mostly Gen0 only
Use benchmark output in your environment to compare trade-offs for your workloads.
๐ง Why this exists
Most PDF generation tools force teams to use low-level primitives or separate template systems. H2Pdf keeps PDF authoring in your existing .NET workflow with:
- component-driven composition
- familiar Razor syntax
- predictable, code-reviewable output
๐ฃ Roadmap
See ROADMAP.md.
๐ค Contributing
We welcome PRs and ideas. Start with CONTRIBUTING.md.
โญ Star History
๐ Architecture
High-level internals are documented in Architecture.md.
๐ License
MIT โ see LICENSE.
| 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.2.0)
- Microsoft.AspNetCore.Components (>= 10.0.3)
- Microsoft.AspNetCore.Components.Web (>= 10.0.3)
- MigraDocCore.DocumentObjectModel (>= 1.3.67)
- MigraDocCore.Rendering (>= 1.3.67)
- PdfSharpCore (>= 1.3.67)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1 | 54 | 2/15/2026 |
Release notes will be added in upcoming releases.