---
type: Article
title: Generate PDFs in Python with gotenberg-client and Marqius Kern | Marqius
description: A practical Python example for HTML and CSV conversion, with
  gotenberg-client, compatibility results and migration checks.
resource: https://marqius.com/blog/python-gotenberg-client-marqius-kern/
tags:
  - marqius
  - journal
status: stable
sources:
  - id: official-page
    resource: https://marqius.com/blog/python-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: 4646a8e69558a328f4bb0e6aedbd4d26f5abe86099c4d2306b32808721ce82a3
  extraction: public-main-content
---

Marqius Kern developers

# Generate PDFs in Python with gotenberg-client and Marqius Kern

gotenberg-client calls Gotenberg's API at the address you give it. Marqius Kern answers that API, Gotenberg 8's and 9's, from a 41 MB image: change the image your compose file or manifest runs, and your Python code stays as it is.

Marqius December 2, 2026

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

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

text

```
image: marqius/kern
```

* * *

## gotenberg-client and Marqius Kern, in one folder.

gotenberg-client, the client Paperless-ngx uses, calls the address you give `GotenbergClient` (in Paperless-ngx, `PAPERLESS_TIKA_GOTENBERG_ENDPOINT`); that address stays as it is.

**You need:** Docker, curl and Python 3.10 or later.

**It takes:** about 5 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. Install the client

`python3 -m venv .venv` makes a virtual environment: a folder, `.venv`, that keeps this project's packages apart from the rest of your machine. Then pip installs the client, version 1.2.0, with its httpx backend.

bash

```
python3 -m venv .venv
.venv/bin/pip install "gotenberg-client[httpx]==1.2.0"
```

**You should see:** pip's progress, then a last line that begins `Successfully installed` and names `gotenberg-client-1.2.0` among the packages.

### Step 3. 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 4. Write the program

The program converts a web page and the price list. Save it as `convert.py`:

python convert.py

```
from pathlib import Path

from gotenberg_client import GotenbergClient

with GotenbergClient("http://localhost:3000") as client:
    with client.chromium.html_to_pdf() as route:
        page = "<h1>Invoice 1001</h1><p>Thank you for your order.</p>"
        route.string_index(page).run().to_file(Path("invoice.pdf"))
    with client.libre_office.to_pdf() as route:
        route.convert(Path("prices.csv")).run().to_file(Path("prices.pdf"))

print("Saved invoice.pdf and prices.pdf")
```

### Step 5. Run it, then stop Marqius Kern

bash

```
.venv/bin/python convert.py
docker stop kern
```

**You should see:**

text

```
Saved invoice.pdf and prices.pdf
kern
```

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

**If it does not work:**

-   **`docker run` says the name `kern` is already in use:** a container left from an earlier try still has it. Remove it with `docker rm -f kern`, then start again from step 1.
-   **`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).
-   **The `curl` command in step 1 gives up with an error:** `docker logs kern` shows Marqius Kern's messages.
-   **`python3 -m venv` says `ensurepip is not available`** (on Ubuntu and Debian): install the package `python3-venv`, then run step 2 again.

**What differs from Gotenberg:** No differences were reported in the library tests referenced below. Those results do not establish identical output for every document. What differs for Paperless-ngx itself is on [the Paperless-ngx page](https://marqius.com/gotenberg/paperless-ngx).

**What to check after switching:**

-   if your compose file gives `--chromium-allow-list` more than once (the client's own test setup does), every entry counts, as in Gotenberg;
-   `client.health.health()` reports Chromium and LibreOffice as up, so a readiness check written for Gotenberg keeps passing.

* * *

## 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-client 1.2.0's own tests

 | 

481

 | 

481

 |
| 

Haystack's Gotenberg converter's own tests

 | 

4

 | 

4

 |

[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-client work with Marqius Kern?

Yes. Its own tests, all 481 that pass against Gotenberg, pass against Marqius Kern on the public scoreboard. Give GotenbergClient the server's address, as you would Gotenberg's.

### Is gotenberg-client written for Gotenberg 8 or 9?

gotenberg-client 1.2.0 is written for Gotenberg 8's API. Marqius Kern answers Gotenberg 8's API, maintained, and Gotenberg 9's beside it.

### Does Paperless-ngx use gotenberg-client?

Yes: Paperless-ngx calls Gotenberg through gotenberg-client. Its own page, marqius.com/gotenberg/paperless-ngx, shows the switch for Paperless-ngx.

### 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/python-gotenberg-client-marqius-kern/

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