HTML to PDF for .NET. Chromium precision or WebKit efficiency.
Generate pixel-perfect PDFs from any URL or HTML in C# — headers, watermarks, encryption and more, in a few lines of code. Pick Chromium for maximum fidelity and speed, or WebKit for a lighter, self-contained Linux footprint — one fluent API, one license.
dotnet add package CobaltPdf
dotnet add package CobaltPdf.WebKit
* Free evaluation mode runs without a license key for as long as you need. Output is watermarked until a license is activated.
using CobaltPdf;
// Render a URL to PDF
await new CobaltEngine()
.RenderUrlAsPdfAsync("https://example.com")
.SaveAsAsync("website.pdf");
// Render an HTML string to PDF
await new CobaltEngine()
.RenderHtmlAsPdfAsync("<h1>Hello, World!</h1>")
.SaveAsAsync("hello.pdf");
// Render a local HTML file to PDF
await new CobaltEngine()
.RenderHtmlFileAsPdfAsync("invoice.html")
.SaveAsAsync("invoice.pdf");
A complete PDF toolkit. In both libraries.
Generate, secure, split and customise PDFs — the same fluent API in CobaltPDF and CobaltPDF.WebKit.
True Browser Rendering
Real Chromium & WebKit — HTML5, CSS Grid, web fonts, JS.
Headers & Footers
Dynamic HTML with page-number, date & custom tokens.
Cookies & Auth
Inject cookies, storage & headers to render gated pages.
AES-256 Encryption
User/owner passwords with print, copy & modify controls.
PDF Metadata
Embed title, author, subject, keywords & creator.
Custom JavaScript
Run JS before capture to trigger loaders or set state.
Wait Strategies
Network-idle, selector, JS expression, delay or manual.
Cloud-Ready Presets
One-line setup for Docker, Azure, AWS & bare-metal.
Microservice Mode
Standalone HTTP service via CobaltPDF.Requests.
Watermarks
Text or HTML — or rasterized so they can't be removed.
Split, Extract & Merge
Split, extract or merge any PDF — even external ones.
Custom Fonts
Load fonts from disk so servers render text correctly.
Image Compression
Re-encodes embedded images to shrink output — on by default.
Pick the engine that
fits the job.
CobaltPDF and CobaltPDF.WebKit are two separate libraries that share the same fluent API, the same options, and the same license key. Use one, the other, or both side by side.
CobaltPDF
The full Chromium rendering stack. Every modern CSS feature, every JavaScript API — pixel-perfect to what you see in Chrome.
- Full HTML5 / CSS3 / Flexbox / Grid / web fonts
- Modern JavaScript — React, Vue, Angular, SPAs
- Warm browser pool for high-concurrency workloads
- Windows, Linux, Docker, Azure & AWS in production
dotnet add package CobaltPdf
CobaltPDF.WebKit
A lean WebKit-based renderer with the same fluent API and a lighter, self-contained Linux footprint. Built for Linux containers and high-volume pipelines.
- Modern HTML5 & CSS3 — Flexbox, Grid, transforms
- Identical fluent API — a drop-in code swap
- Self-provisioning on managed Linux (App Service / Functions) — no apt, no system setup
- The modern replacement for wkhtmltopdf
Linux-native engine. Runs in production on Linux x64/arm64 — Azure App Service, AKS, ECS/Fargate, any Ubuntu or Alpine container. Develop on Windows via WSL2 or Docker Desktop.
dotnet add package CobaltPdf.WebKit
* Idle heap (RSS) after warm-up, both engines measured identically on the same Linux host rendering the same document: ~130 MB (WebKit) vs ~240 MB (Chromium). Chromium renders faster; WebKit uses less idle memory and releases it between renders. The ~3 MB figure is the WebKit NuGet package — its render bundle self-provisions on first use. See the WebKit edition docs for methodology.
Same document.
A lighter idle footprint.
CobaltPDF.WebKit is engineered for density. Measured identically on the same Linux host, the WebKit engine idles at roughly 40% less memory than Chromium and releases it between renders — so a memory-constrained host can hold more idle workers. The trade-off is render speed: Chromium is faster.
- Releases memory back to the host between renders
- Built-in memory metrics on every render
- Same fluent code — just swap the
usingstatement - Same pooling, AES-256 encryption, watermarks & metadata
A fluent API that
reads like prose.
Every option chains. Every method has a sensible default. No XML config, no boilerplate, no ceremony — just clean, readable code that renders exactly what you mean, in either library.
var pdf = await new CobaltEngine()
.WithPaperFormat("A4")
.WithMargins(new MarginOptions(15, MarginUnit.Millimeters))
.WithHeader("<b>Q3 Report</b>")
.WithFooter("Page <span class='pageNumber'/>")
.WithEncryption(new PdfEncryptionOptions { UserPassword = "user123", OwnerPassword = "owner456" })
.WithMetadata(m => {
m.Title = "Q3 Financial Report";
m.Author = "Finance Team";
})
.RenderUrlAsPdfAsync(reportUrl);
await blobStorage.UploadAsync(pdf.BinaryData);
No cold-start.
Just fast.
Spawning a new browser process for every PDF is expensive — often costing over a second before rendering even begins. Both CobaltPDF libraries keep a pool of warm renderer instances ready to go, so every request skips the cold-start tax entirely.
- Configurable pool with min/max renderer count
- Renderers recycled after N renders — no memory leaks
- Thread-safe: concurrent renders from one instance
-
Optional
PreWarmAsync()to eliminate first-request latency
Why developers choose CobaltPDF
A side-by-side look at what matters in production.
| Feature | CobaltPDF | PuppeteerSharp | wkhtmltopdf | iTextSharp |
|---|---|---|---|---|
| Modern CSS support | ✓ | ✓ | ✗ | ✗ |
| Choice of engine (Chromium or lightweight WebKit) | ✓ | ✗ | ✗ | ✗ |
| Browser pool (no cold-start) | ✓ | ✗ | ✗ | ✗ |
| Fluent .NET API | ✓ | Partial | ✗ | Partial |
| Engine bundled via NuGet | ✓ | ✗ | ✗ | ✗ |
| Cookie & auth injection | ✓ | ✓ | Limited | ✗ |
| PDF encryption (AES-256) | ✓ | ✗ | Limited | ✓ |
| Split, extract & merge pages | ✓ | ✗ | ✗ | ✓ |
| Cloud environment presets | ✓ | ✗ | ✗ | ✗ |
| Microservice support | ✓ | ✗ | ✗ | ✗ |
| Actively maintained | ✓ | ✓ | ✗ archived | ✓ |
Start rendering PDFs
in minutes.
Both libraries run free, unlimited, in evaluation mode — watermarked output until you activate. One key unlocks both.