Getting Started
1. Install
dotnet add package CobaltPDF.WebKit
2. Set the license
using CobaltPdf.WebKit;
CobaltEngine.SetLicense(Environment.GetEnvironmentVariable("COBALTPDF_LICENSE")!);
Without a key the library runs in evaluation mode and watermarks its output. One CobaltPDF key activates both the WebKit and Chromium editions — see Licensing.
3. Render
var engine = new CobaltEngine();
// From a URL
var pdf = await engine.RenderUrlAsPdfAsync("https://example.com");
await pdf.SaveAsAsync("example.pdf");
// From an HTML string
var invoice = await engine
.WithPaperFormat("A4")
.WithMargins(MarginOptions.Default)
.RenderHtmlAsPdfAsync("<h1>Invoice #1042</h1>");
The fluent API is identical to CobaltPDF (Chromium) — every With… method, wait strategy,
watermark, header/footer, encryption, and metadata option works the same way, and each is
documented on this site: Rendering, Wait Strategies,
Cookies & Storage, Headers, Footers & Watermarks,
Fonts, Encryption, Splitting & Merging,
Lazy Loading, Dependency Injection, and more.
What happens on first render
The first render provisions the engine, once per machine:
- Linux — downloads the self-contained WebKit bundle (~262 MB), verifies its SHA-256, extracts it (~611 MB), and warms a render worker. A console notice shows progress; later renders start in milliseconds. See The Render Bundle.
- Windows — the same bundle is installed into your default WSL 2 distro
automatically (any distro with glibc ≥ 2.35;
wsl --install Ubuntu-24.04if you have none). No WSL? The library falls back to Docker Desktop, pulling a public dev image. See Rendering Backends.
4. Warm up at application start (recommended for servers)
// Program.cs — provisions the bundle and spawns MinSize warm workers
// off the request path, so the first user request is fast.
await CobaltEngine.PreWarmAsync();
Next steps
- Deployment — Azure Functions / App Service / Docker / AWS, validated walkthroughs
- Configuration — pool sizing, timeouts, memory caps
- The Render Bundle — caching, air-gapped hosting, self-hosting