---
type: Article
title: Connect your .NET PDF client to Marqius Kern | Marqius
description: Run Gotenberg.Sharp.API.Client against Gotenberg 8 and 9 API modes
  with a complete C# console example.
resource: https://marqius.com/blog/dotnet-gotenberg-client-marqius-kern/
tags:
  - marqius
  - journal
status: stable
sources:
  - id: official-page
    resource: https://marqius.com/blog/dotnet-gotenberg-client-marqius-kern/
    last_modified: 2026-12-02T08:19:13.762Z
generated:
  by: process:marqius-site-build
  at: 2026-12-02T08:32:12.045Z
x_marqius:
  language: en
  source_sha256: 50fc4d8bfed383f2e94654bf2ceddc39b8137acee37b92eb42153941ec2db14c
  extraction: public-main-content
---

Marqius Kern developers

# Connect your .NET PDF client to Marqius Kern

Gotenberg.Sharp.API.Client calls Gotenberg's API at the address you give it. Marqius Kern answers that API, Gotenberg 8's and 9's on one server, from a 41 MB image: change the image your compose file or manifest runs, and your .NET code stays as it is.

Marqius December 2, 2026

[Try it](https://marqius.com/blog/dotnet-gotenberg-client-marqius-kern/#the-net-client-and-marqius-kern-in-one-folder) · [Review compatibility results](https://marqius.com/blog/dotnet-gotenberg-client-marqius-kern/#compatibility-results)

The container image to use in your Compose file or deployment manifest:

text

```
image: marqius/kern
```

* * *

## The .NET client and Marqius Kern, in one folder.

The client calls `GotenbergSharpClient:ServiceUrl` (the `ServiceUrl` option, or the `BaseAddress` of the `HttpClient` you give it); that setting stays as it is. Version 4 reads the server's `/version` and sends each request in that version's form: Gotenberg 8's while Marqius Kern reports 8.40.0, Gotenberg 9's when it reports 9.10.3. The steps below run the same program in both forms.

**You need:** Docker, curl and the .NET 8 SDK or later.

**It takes:** about 10 minutes.

### Step 1. Start Marqius Kern

In a new, empty folder, start Marqius Kern and wait until it answers. The first command starts it in the background, as a container named `kern` on port 3000; the second asks its health check until it answers.

bash

```
docker run --rm -d --name kern -p 3000:3000 marqius/kern
curl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/health
```

**You should see:** a long string of letters and digits (the container's ID), then a line that begins `{"status":"up"`.

### Step 2. Make a console application

This makes a console application in a folder named `Invoices`, and goes into it.

bash

```
dotnet new console -o Invoices
cd Invoices
```

**You should see:** `The template "Console App" was created successfully.`, and at the end `Restore succeeded.`

### Step 3. Add the client

This adds the client, version 4.0.0, from NuGet.

bash

```
dotnet add package Gotenberg.Sharp.Api.Client --version 4.0.0
```

**You should see:** NuGet's progress, in lines that begin `info :`, among them `info : PackageReference for package 'Gotenberg.Sharp.API.Client' version '4.0.0' added to file` and the path of your `Invoices.csproj`.

### Step 4. Make a small price list

bash

```
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csv
```

**You should see:** nothing printed; the folder now holds `prices.csv`.

### Step 5. Write the program

Replace what is in `Program.cs` with:

csharp Program.cs

```
using Gotenberg.Sharp.API.Client;
using Gotenberg.Sharp.API.Client.Application.Builders;

var client = new GotenbergSharpClient(new HttpClient { BaseAddress = new Uri("http://localhost:3000") });
Console.WriteLine($"Gotenberg API: {await client.GetApiVersionAsync()}");

var invoice = new HtmlRequestBuilder()
    .AddDocument(doc => doc.SetBody("<html><body><h1>Invoice 1001</h1><p>Thank you for your order.</p></body></html>"));
await Save(await client.HtmlToPdfAsync(invoice), "invoice.pdf");

var prices = new MergeOfficeBuilder()
    .WithAssets(assets => assets.AddItem("prices.csv", File.ReadAllBytes("prices.csv")));
await Save(await client.MergeOfficeDocsAsync(prices), "prices.pdf");

Console.WriteLine("Saved invoice.pdf and prices.pdf");

static async Task Save(Stream pdf, string path)
{
    await using var file = File.Create(path);
    await pdf.CopyToAsync(file);
}
```

### Step 6. Run it

The program first prints the form the client chose: Gotenberg 8's, as Marqius Kern reports 8.40.0.

bash

```
dotnet run
```

**You should see:**

text

```
Gotenberg API: V8
Saved invoice.pdf and prices.pdf
```

There are now two new files in the `Invoices` folder: `invoice.pdf`, with the heading Invoice 1001, and `prices.pdf`, with the price list.

### Step 7. Start Marqius Kern again, as Gotenberg 9

Now the same program in Gotenberg 9's form. The first command stops Marqius Kern. The second starts it again, as a container named `kern9`, with `KERN_GOTENBERG_VERSION=9.10.3`: it then reports 9.10.3 and answers a request that names neither version as Gotenberg 9 does. The third waits until it answers.

bash

```
docker stop kern
docker run --rm -d --name kern9 -p 3000:3000 -e KERN_GOTENBERG_VERSION=9.10.3 marqius/kern
curl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/health
```

**You should see:** `kern`, then the new container's ID, then a line that begins `{"status":"up"`.

### Step 8. Run it again, then stop Marqius Kern

The client reads 9.10.3, so it sends Gotenberg 9's requests, and prints `Gotenberg API: V9`.

bash

```
dotnet run
docker stop kern9
```

**You should see:**

text

```
Gotenberg API: V9
Saved invoice.pdf and prices.pdf
kern9
```

**If it does not work:**

-   **`docker run` says the name `kern` (or `kern9`) is already in use:** a container left from an earlier try still has it. Remove it with `docker rm -f kern` (or `docker rm -f kern9`), then run that step again.
-   **`docker run` says port 3000 is already allocated or in use:** another server listens on it, often your old Gotenberg. Stop that first (`docker ps` lists the running containers).
-   **A `curl` command gives up with an error:** `docker logs kern` (or `docker logs kern9`) shows Marqius Kern's messages.

**What differs from Gotenberg:**

-   The listed client tests pass against Marqius Kern: 43 of 43 in Gotenberg 8's form and 59 of 59 in Gotenberg 9's. These counts do not cover every operation; the limitations below still apply.
-   In Gotenberg 9's form, every operation is answered, typed or added with `Add(op, ...)`. What Marqius Kern does not do yet is answered 501, with the reason: on the LibreOffice route, Gotenberg 9's `paperSize`, `paperWidth`, `paperHeight`, `locale` and `showTrackedChanges`; on a signed PDF, the edits Gotenberg 9 adds to it as an update (rotating pages, setting metadata or bookmarks, attaching or removing files, autotagging; stamps are added as Gotenberg adds them, and the signatures stay); and remediation to PDF/A-4e.

**What to check after switching:**

-   `GetGotenbergVersionAsync()` returns the version Marqius Kern reports (8.40.0, or 9.10.3), not its own: the `X-Marqius-Kern` header of `/version` names that;
-   to choose the form yourself, set `GotenbergSharpClient:ApiVersion` to `V8` or `V9`: the client then skips its `/version` lookup;
-   with basic auth (`BasicAuthUsername`, `BasicAuthPassword`), start Marqius Kern with `--api-enable-basic-auth` and Gotenberg's variables, as the client's own tests do.

* * *

## Compatibility results

The public Marqius compatibility scoreboard reports these results for Marqius Kern 0.12.18, tested on 30 November 2026 and reviewed here on 2 December 2026. The counts cover the named libraries’ or applications’ assertions, not identical rendering of every customer PDF. Compare your own documents before switching.

| 
Library and version

 | 

Pass on Gotenberg

 | 

Pass on Marqius Kern

 |
| --- | --- | --- |
| 

Gotenberg.Sharp.API.Client 4.0.0's own tests, Gotenberg 8's API

 | 

43

 | 

43

 |
| 

The same tests, Gotenberg 9's API

 | 

59

 | 

59

 |

[See every test on the scoreboard](https://github.com/marqiushq/gotenberg-compatibility#the-results)

* * *

## Licensing Marqius Kern

**Personal, teaching and open-source use is free** with a Community licence, including open-source projects' CI runs and documentation builds.

1.  **Get your free key** on [the Marqius Kern licence page](https://marqius.com/licence/marqius-kern), then sign in with Google.
2.  Tick "I'll use Marqius Kern only for personal, teaching or open-source work".
3.  **Get my free key**, then **Copy key**.
4.  Set it as the variable `MARQIUS_LICENCE` on your server.

**Anything done by or for a business,** including internal tools and client work, needs a paid licence. [See the plans and prices](https://marqius.com/licence/marqius-kern).

* * *

## Deploy Marqius Kern on Railway

For a hosted PDF server, start with the [Marqius Kern deployment template on Railway](https://railway.com/deploy/marqius-kern). The examples in this guide run locally; when using Railway, configure your client with the service’s HTTPS address and the generated credentials shown in its Variables tab.

[Deploy Marqius Kern on Railway](https://railway.com/deploy/marqius-kern)

## Before you switch

Compare your own documents side by side first, as the switching guide shows, then switch.

[Read the switching guide](https://marqius.com/gotenberg/guide) · [Get your free key](https://marqius.com/licence/marqius-kern)

[Explore all nine Marqius Kern developer guides](https://marqius.com/gotenberg/developers/)

## Reader questions

### Does Gotenberg.Sharp.API.Client work with Marqius Kern?

Yes, in both its forms. Its own tests pass against Marqius Kern as against Gotenberg on the public scoreboard: 43 of 43 with Gotenberg 8's API, and 59 of 59 with Gotenberg 9's.

### Do I need to change the client's settings?

No. It keeps the server's address it has; the switch is the image your compose file or manifest runs.

### How do I add my licence?

Personal, teaching and open-source use is free with a Community licence: get the key on [the Marqius Kern licence page](https://marqius.com/licence/marqius-kern) and set it as the variable MARQIUS\_LICENCE on the server. Without a key, Marqius Kern makes the same documents and says in its log that it has none. Anything done by or for a business needs a paid licence.

## Keep reading

[Marqius Kern guides for every client](https://marqius.com/gotenberg/developers/) [Use Marqius Kern with Ruby and Rails](https://marqius.com/blog/ruby-rails-gotenberg-marqius-kern/) [Generate PDFs in Swift with gotenberg-kit and Marqius Kern](https://marqius.com/blog/swift-gotenberg-kit-marqius-kern/) [Generate PDFs in Rust with gotenberg\_pdf and Marqius Kern](https://marqius.com/blog/rust-gotenberg-pdf-marqius-kern/) [All journal guides](https://marqius.com/blog/)

Source for this page [^official-page].

[^official-page]: https://marqius.com/blog/dotnet-gotenberg-client-marqius-kern/

[Browse this section](index.md) · [Knowledge index](../index.md)
