HTML to PDF. Perfectly.
CobaltPdf is a fast, fluent .NET 8 library that converts HTML pages and strings into pixel-perfect PDFs using a managed Chromium browser pool. Zero warm-up lag on subsequent requests, a clean chainable API, and first-class support for cookies, storage injection, custom JavaScript, fonts, watermarks, encryption, metadata, and cloud deployments.
Quick Start
using CobaltPdf;
using CobaltPdf.Configuration;
// One-time setup — call once at startup before any renders
// Use a CloudEnvironment preset for Linux, Docker, Azure, or AWS
CobaltEngine.Configure(CloudEnvironment.ConfigureForDocker);
// Render a URL
var renderer = new CobaltEngine();
var pdf = await renderer.RenderUrlAsPdfAsync("https://example.com");
pdf.SaveAs("output.pdf");
// Render an HTML string (in memory — no file written)
var pdf2 = await renderer.RenderHtmlAsPdfAsync("<h1>Hello World</h1>");
Console.WriteLine($"{pdf2.Length} bytes");
Highlights
| Feature | Details |
|---|---|
| Browser pooling | Chromium instances kept warm between requests — no per-request startup cost |
| Fluent API | Chain options naturally: renderer.Landscape().AddCookie(…).RenderUrlAsPdfAsync(…) |
| Cloud presets | CloudEnvironment presets for Linux, Docker, Azure, and AWS in a single call |
| Wait strategies | Network idle, fixed delay, CSS selector, JavaScript expression, or manual signal |
| Cookie injection | Set cookies before navigation; domain auto-inferred after redirects |
| Storage injection | localStorage and sessionStorage populated before the page loads |
| Custom JavaScript | Execute arbitrary JS before capture; use window.cobaltNotifyRender() for precise control |
| Fonts | Point to a local directory — any .ttf, .otf, .woff, .woff2 file injected automatically |
| Headers & Footers | HTML templates with pageNumber / totalPages tokens |
| Watermarks | HTML overlay, fully positionable, with rotation and opacity |
| Encryption | User + owner passwords, print/copy/modify permissions |
| Metadata | Title, author, subject, keywords, creator embedded in the PDF |
| Lazy loading | Scroll N viewport-heights before capture to trigger infinite-scroll content |
| DI support | services.AddCobaltPdf(…) for ASP.NET Core / generic host |
| Microservice-ready | CobaltPDF.Requests companion package — clients send JSON payloads without installing Chromium |
| Licensing | Call CobaltEngine.SetLicense(key) to remove the trial watermark |
Documentation
- Introduction — what CobaltPdf is and how it works
- Prerequisites — runtime requirements
- Chromium Setup — how Chromium is bundled and how to control it
- Getting Started — install and render your first PDF
- Configuration — global pool settings, cloud presets, and logging
- Rendering — URL, HTML string, and HTML file rendering
- Cookies & Storage — authentication and session flows
- Wait Strategies — controlling when the PDF capture fires
- Custom JavaScript — injecting scripts before capture
- Page Numbering —
pageNumber/totalPagestokens - Headers, Footers & Watermarks
- Fonts — custom local font injection
- Encryption — password protection and permissions
- Metadata — title, author, subject, keywords
- Lazy Loading — infinite-scroll and deferred content
- Dependency Injection — ASP.NET Core integration
- HTTP Requests —
CobaltPDF.Requestsmicroservice pattern, JSON schema, Azure Function and ASP.NET Core examples - CobaltPDF.Requests — full property reference, Azure Function, AWS Lambda, ECS, and ASP.NET Core server examples
- Deployment — Docker, Azure, AWS, and Linux step-by-step guides
- Licensing
- API Reference — full generated reference docs