.NET C# client for Gotenberg v7 & v8 — a Docker-powered stateless API for converting & merging HTML, Markdown, and Office documents to PDF. Includes a configurable Polly retry policy with exponential backoff.
v3.1.0 — PDF bookmark read/write, embed files into PDFs (ZUGFeRD / Factur-X), and Gotenberg version compatibility checking with clear errors for unsupported features. See CHANGES.MD for details.
- HTML/URL to PDF with Chromium (page properties, headers/footers, cookies, wait conditions)
- Screenshots of HTML or URLs as PNG, JPEG, or WebP
- Office to PDF via LibreOffice (100+ formats, image compression, watermarks)
- PDF Manipulation — merge, flatten, rotate, split, encrypt, watermark, stamp, embed files
- PDF/A & PDF/UA compliance, metadata & bookmark read/write
- Webhooks for async PDF generation
- DI-Ready with Polly retry policies
docker run --rm -p 3000:3000 gotenberg/gotenberg:latestdotnet add package Gotenberg.Sharp.Api.Client// Startup.cs
services.AddOptions<GotenbergSharpClientOptions>()
.Bind(Configuration.GetSection("GotenbergSharpClient"));
services.AddGotenbergSharpClient();var builder = new HtmlRequestBuilder()
.AddDocument(doc => doc.SetBody("<html><body><h1>Hello PDF!</h1></body></html>"))
.WithPageProperties(pp => pp.UseChromeDefaults());
var result = await sharpClient.HtmlToPdfAsync(builder);var builder = new ScreenshotHtmlRequestBuilder()
.AddDocument(doc => doc.SetBody("<html><body><h1>Screenshot!</h1></body></html>"))
.WithScreenshotProperties(p => p.SetSize(1280, 720).SetFormat(ScreenshotFormat.Png));
var imageStream = await sharpClient.ScreenshotHtmlAsync(builder);var builder = new MergeOfficeBuilder()
.WithAsyncAssets(async a => a.AddItems(await GetDocsAsync(sourceDir)))
.SetLibreOfficeOptions(o => o.SetQuality(85).SetExportBookmarks())
.SetPdfOutputOptions(o => o.SetPdfFormat(PdfFormat.A2b));
var result = await sharpClient.MergeOfficeDocsAsync(builder);// Rotate
using var rotated = await sharpClient.ExecutePdfEngineAsync(
PdfEngineBuilders.Rotate(90).WithPdfs(a => a.AddItem("doc.pdf", bytes)));
// Encrypt
using var encrypted = await sharpClient.ExecutePdfEngineAsync(
PdfEngineBuilders.Encrypt("reader123", "admin456").WithPdfs(a => a.AddItem("doc.pdf", bytes)));
// Watermark (inline, on any conversion)
var builder = new HtmlRequestBuilder()
.AddDocument(doc => doc.SetBody(html))
.SetWatermarkOptions(w => w.SetTextWatermark("DRAFT"));See the full documentation for:
- Getting Started — setup, configuration, DI
- HTML & URL to PDF — Chromium features, page properties, cookies
- Screenshots — PNG/JPEG/WebP capture
- Office Conversion — LibreOffice options
- PDF Manipulation — merge, rotate, split, encrypt, watermark, bookmarks, embedded files
- Advanced Features — webhooks, value objects, version compatibility, multi-URL merge
See the examples folder for complete working console applications.
See CHANGES.MD for the full release history.
GotenbergSharpApiClient is free and open source. If it saves you time, consider sponsoring — sponsorships go directly toward the costs of maintaining Changemaker Studios' open-source projects, like code-signing certificates and development tooling.