.NET C# client for Gotenberg v7, v8 & v9 — a Docker-powered stateless API for converting & merging HTML, Markdown, and Office documents to PDF. It registers as a typed HttpClient, so retries can be added with Microsoft.Extensions.Http.Resilience. If this library saves you time, please ⭐ star it on GitHub — stars are how other developers find it — and consider sponsoring to keep it maintained. v4.0.0 — Gotenberg 9…
.NET C# client for Gotenberg v7, v8 & v9 — a Docker-powered stateless API for converting & merging HTML, Markdown, and Office documents to PDF. It registers as a typed HttpClient, so retries can be added with Microsoft.Extensions.Http.Resilience.
If this library saves you time, please ⭐ star it on GitHub — stars are how other developers find it — and consider sponsoring to keep it maintained.
v4.0.0 — Gotenberg 9 support alongside 7 and 8, Native AOT and trimming support, and System.Text.Json in place of Newtonsoft.Json. This is a breaking release: the built-in Polly retry is gone (see Retries and Timeouts), JObject APIs now take IDictionary<string, object> or JsonObject, and TimeOut covers the whole call. See CHANGES.MD for the full list.
Features
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)
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);
Screenshot
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);
Office to PDF
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);
PDF Operations
// 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"));
Sponsor the project — sponsorships go directly toward the costs of maintaining Changemaker Studios’ open-source projects, like code-signing certificates and development tooling.
If your team relies on GotenbergSharpApiClient in production, a company sponsorship keeps it maintained and puts your logo here and in the docs. GitHub can invoice your organization, so no personal card is needed.
评论