How to use this guide
- Read section 1 first. It says what stays the same and what differs, and shows how to compare your own documents on both servers before you change anything.
- Then follow the section for where your server runs:
- Docker Compose: section 2;
- Paperless-ngx: section 3;
- Kubernetes: section 4;
- Google Cloud Run: section 5;
- Railway, in one click: the end of section 5.
- If your app calls the server through a client library, find your library in section 6: Python, PHP (gotenberg-php, Symfony, Laravel), Node.js, .NET, Go, Kotlin, Spring, Rust, Swift or Ruby.
- Section 7 is about fonts. Section 8 adds your licence. Section 9 says what to do if a document comes out differently, and how to go back.
- To look up a route or a form field, see the API reference: every route of Gotenberg 8.40.0 and 9.10.3 that Marqius Kern answers, with samples.
Each step says what it does, gives the command or file to copy, and then what you should see. Copy the commands into a terminal, one box at a time. The IDs, dates and times on your screen will differ from those shown here.
1. Before you switch
Nothing in your set-up changes in this section. Read what stays the same and what differs, then compare your own documents on both servers.
What stays the same:
- the routes, form fields, defaults, headers and status codes of Gotenberg 8.40.0 and 9.10.3: what your app sends, and what it gets back;
- the
gotenbergcommand, with every Gotenberg 8.40.0 flag and its variable (--api-timeout=60sorAPI_TIMEOUT=60s); - port 3000,
GET /health, andcurlinside the image for health checks. A port is the number a server listens on. A health check is a small request, hereGET /health, that Docker or Kubernetes sends to ask whether the server is ready; - the user
gotenberg(uid 1001, in group root), a read-only root filesystem with/tmpwritable, and a clean stop on SIGTERM (the signal Docker and Kubernetes send to stop a container) within Gotenberg's 30 seconds; - your client library and its settings: the address it calls does not change.
What differs:
- No browser and no office suite inside. Pages that need a real browser (canvas drawing, charts that measure the page while they draw, pages built from
fetch) print without those parts. Word (.docx,.doc), Excel (.xlsx,.xls), PowerPoint (.pptx), CSV, RTF, OpenDocument and plain text are read; Visio, WordPerfect, old PowerPoint.pptand LibreOffice's other rarer formats are refused, with the reason. - Fonts neither server has. In Word, Excel and PowerPoint files, a font such as Verdana, Georgia or Segoe UI is set in a look-alike, or in a font of the same kind (serif, sans-serif or monospaced), where Gotenberg sets it in Noto Serif.
- Letters in other writing systems (Chinese, Japanese, Korean, Thai, emoji) need their font fetched once, on first need, or the image tagged
fonts, which has them inside. Arabic and Hebrew are built in. - Code written for Gotenberg 9: set
KERN_GOTENBERG_VERSION=9.10.3. This is an environment variable: a setting you give the container when it starts, as-e KERN_GOTENBERG_VERSION=9.10.3indocker run. Marqius Kern then reports 9.10.3 on/version(which the .NET client 4 reads to choose its requests) and answers a request that names neither version as Gotenberg 9 does. Without it, it reports8.40.0and answers such requests as Gotenberg 8. - Flags that tune Chromium or LibreOffice (restart counts, queue sizes) are accepted, and the start-up log says they have no effect.
- A licence. Personal, teaching and open-source use is free with a Community licence; anything done by or for a business needs a paid licence. Without a licence, every document is made as before, and the server says that it has none in its log and in one header on its answers. Section 8 shows how to add yours.
- Each difference is listed, with its test, on the scoreboard.
Compare your own documents first
Run both servers side by side and send your own documents through both. upgrade-check, a tool inside the Marqius Kern image, converts each document with each server and compares the PDFs for what they say and how they look.
You need: Docker.
It takes: about 5 minutes, plus the time Docker takes to download the two images the first time.
Step 1. Start both servers on one Docker network
Open a terminal in a new, empty folder. The first command makes a Docker network named pdf-check: a private network on which containers reach each other by name. The next two start Gotenberg 8 and Marqius Kern on it, as containers named gotenberg and kern (a container is a running copy of an image). -d runs each one in the background, and --rm removes it when it stops.
docker network create pdf-checkdocker run --rm -d --name gotenberg --network pdf-check gotenberg/gotenberg:8docker run --rm -d --name kern --network pdf-check marqius/kernYou should see: three long strings of letters and digits: the network's ID, then each container's ID. The first time, Docker downloads each image before it starts it, and shows its progress.
Step 2. Put a few of your documents in a folder named samples
Use documents your app really sends: an invoice page, a Word file, a spreadsheet. Here, two made-up ones, a web page and a small price list:
mkdir samplesecho '<h1>Invoice 1001</h1><p>Thank you for your order.</p>' > samples/invoice.htmlprintf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > samples/prices.csvYou should see: nothing printed. The folder samples now holds invoice.html and prices.csv.
Step 3. Wait until Gotenberg is ready
This command asks Gotenberg's health check, and tries again every second, up to ten times, until it answers. It runs curl from the Marqius Kern image, on the same network, so you need nothing else installed.
docker run --rm --network pdf-check marqius/kern curl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://gotenberg:3000/healthYou should see: one line that begins {"status":"up": Gotenberg is ready.
Step 4. Compare the two servers
This runs upgrade-check from the Marqius Kern image:
-v "$PWD:/work" -w /workshares your current folder with the container as/work, and works there;--user "$(id -u):$(id -g)"runs it as you, so the report's files are yours;--oldnames the server you have now and--newthe one you are moving to; then come the folder of samples and, after-o, the folder for the report.
docker run --rm --network pdf-check -v "$PWD:/work" -w /work --user "$(id -u):$(id -g)" marqius/kern marqius-kern upgrade-check --old http://gotenberg:3000 --new http://kern:3000 samples/ -o report/You should see a summary of what it found, like this one from 29 November 2026:
marqius-kern upgrade-check: 2 samples
old: http://gotenberg:3000 (Gotenberg 8.40.0 (not kern: its PDFs are compared all the same))
new: http://kern:3000 (marqius-kern 0.12.20, answering as Gotenberg 8.40.0)
marqius-kern compare: report/old against report/new
2 pairs compared in 0.0 s (79 a second on 4 cores)
same 0
appearance only 2
content differs 0
by level: blocking 0, review 1, cosmetic 1
REVIEW: nothing blocking; 1 document to look at
The 2 documents that differ, by cause (4 causes in all; a document may have several):
1. review 1 document pdf type: version 1.4 → 1.7
2. cosmetic 1 document lines break at other words
3. cosmetic 1 document metadata: title gone
4. cosmetic 1 document moved 10 pt downStep 5. Read the result
Every word of both documents is there in both (content differs 0). What it lists for the two made-up samples:
- pdf type: version 1.4 → 1.7: Gotenberg 8 writes web pages as PDF 1.4, Marqius Kern as PDF 1.7. Every PDF reader opens both.
- metadata: title gone: the page has no
<title>, so Gotenberg names the file after its temporary file name, and Marqius Kern gives it no title. - moved 10 pt down and lines break at other words: the invoice's two lines stand 10 points lower, and the spreadsheet's columns are spaced differently.
It ends with GO, REVIEW or NO-GO, and with status 1 when there is something to look at (the exit status, which a script can test). report/ holds both servers' PDFs (old/, new/), marked-up copies of the pages that differ with a picture of each (compare/pairs/), and the table of requests with each server's time (requests.tsv). Open the pictures in report/compare/pairs/ to see each difference marked on the page. A document set in another font is one to look at: it usually means a font your documents use is missing from the server (section 7).
Step 6. Stop both servers
The containers are removed as they stop, because they were started with --rm. The second command removes the network.
docker stop gotenberg kerndocker network rm pdf-checkYou should see:
gotenberg
kern
pdf-checkIf it does not work:
docker runsays the namegotenbergorkernis already in use: a container left from an earlier try still has it. Remove both withdocker rm -f gotenberg kern, then start again from step 1.docker network createsays the networkpdf-checkalready exists: it is left from an earlier try, and the next two commands still work with it.- The command in step 3 gives up with an error: Gotenberg is not answering yet. Run the command again; if it still fails,
docker logs gotenbergshows Gotenberg's own messages.
2. Docker Compose
A compose file (compose.yaml, or docker-compose.yml in older set-ups) lists the containers that Docker Compose starts together, each with its image and settings. To switch, change the image line. Keep the service's name, so the address your app calls (http://gotenberg:3000) stays the same. In the box below, the line marked - comes out and the line marked + goes in:
services:
gotenberg:
- image: gotenberg/gotenberg:8
+ image: marqius/kern
You need: Docker with Docker Compose (the docker compose command), and curl.
It takes: about 5 minutes.
The steps below try the switch in an empty folder first, with a complete compose file, before you change your own.
Step 1. Write a complete compose file
In a new, empty folder, save this as compose.yaml. It has the flags people pass most often:
commandruns thegotenbergcommand with two of Gotenberg's flags, as you may have them now;portsmakes the container's port 3000 reachable as port 3000 on your machine;healthcheckhas Docker ask/healthevery 10 seconds, and mark the server unhealthy after 3 failures in a row.
services:
gotenberg:
image: marqius/kern
command:
- gotenberg
- --api-timeout=60s
- --chromium-disable-javascript=true
ports:
- "3000:3000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 3Step 2. Start the server
up starts what the compose file lists. -d runs it in the background, and --wait waits until the health check passes. The first time, Docker downloads the image.
docker compose up -d --waitYou should see: Docker Compose report each thing it creates and starts. The last line names the container and ends with Healthy, such as Container f2-gotenberg-1 Healthy for a folder named f2.
Step 3. Convert a page to PDF, then stop the server
The first command sends a one-line web page to /forms/chromium/convert/html, the address Gotenberg uses for web pages, as your app would; -F 'files=@-;filename=index.html' sends what echo prints as a file named index.html, and -o invoice.pdf saves the answer. The second command stops and removes the container.
echo '<h1>Invoice 1001</h1>' | curl -sS --fail -F 'files=@-;filename=index.html' -o invoice.pdf http://localhost:3000/forms/chromium/convert/htmldocker compose downYou should see: nothing from the first command, and a new file, invoice.pdf, in the folder: open it to see the heading Invoice 1001. Docker Compose then reports the container and its network stopped and removed.
Step 4. Change your own compose file
Make the change shown at the top of this section in your own compose file. Then run docker compose up -d in its folder: Docker Compose starts the service again with the new image.
If it does not work:
- Docker says port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first:
docker compose downin its folder, ordocker stopwith its container's name (docker pslists the running containers). --waitends with the container unhealthy:docker compose logsshows the server's messages.
What to check after switching:
docker compose psshows the service healthy;- one document of each kind your app sends (an invoice, a Word file, a merge) comes back as before;
- your logs: the start-up lines name
marqius-kern, your licence (section 8) and any flag that has no effect.
3. Paperless-ngx
Paperless-ngx sends Office files to Gotenberg, and emails with their attachments, to make the PDFs it archives. The switch is the image of its gotenberg service.
Switch your Paperless-ngx
You need: the folder that holds your Paperless-ngx docker-compose.yml.
Step 1. Change the image line
In your docker-compose.yml, change the image of the gotenberg service and keep its command:
gotenberg:
- image: docker.io/gotenberg/gotenberg:8.38
+ image: marqius/kern
restart: unless-stopped
command:
- "gotenberg"
- "--chromium-disable-javascript=true"
- "--chromium-allow-list=^file:///tmp/.*"
PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000 stays as it is.
Step 2. Make the change and restart
The first command makes the change in the folder that holds your docker-compose.yml, keeping the old file as docker-compose.yml.bak. The second starts the gotenberg service again with the new image.
sed -i.bak 's#image: docker.io/gotenberg/gotenberg:.*#image: marqius/kern#' docker-compose.ymldocker compose up -dThe first command changes the line only where it reads image: docker.io/gotenberg/gotenberg: and a version, as in Paperless-ngx's own compose files. If yours is written another way, change it by hand, as in step 1.
Try it on a new Paperless-ngx
To see the switch work before you touch your own, try it on a new Paperless-ngx, from Paperless-ngx's own compose files with Tika and Gotenberg, in an empty folder. Paperless-ngx asks for a secret key of your own and an administrator account; step 3 sets both.
You need: Docker with Docker Compose, curl and openssl, and a Word file and an email (an .eml file) of your own.
It takes: about 10 minutes, plus the time Docker takes to download Paperless-ngx's images the first time.
Step 1. Download Paperless-ngx's compose files
In a new, empty folder, download the three files Paperless-ngx publishes for an installation with Tika and Gotenberg: the compose file, its settings (docker-compose.env) and .env.
curl -fsSL -o docker-compose.yml https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/docker-compose.sqlite-tika.ymlcurl -fsSL -o docker-compose.env https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/docker-compose.envcurl -fsSL -o .env https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/.envYou should see: nothing printed. The three files are now in the folder.
Step 2. Change the image line
The same command as for your own Paperless-ngx: it puts marqius/kern in place of Gotenberg's image.
sed -i.bak 's#image: docker.io/gotenberg/gotenberg:.*#image: marqius/kern#' docker-compose.ymlYou should see: nothing printed.
Step 3. Set a secret key and an administrator account
The first command puts a secret key of your own in docker-compose.env: a random one, made by openssl rand -hex 32. The second adds an administrator account, admin, with the password try-marqius-kern. That password is for this try only; on a real installation, choose your own.
sed -i.bak "s#^PAPERLESS_SECRET_KEY=.*#PAPERLESS_SECRET_KEY=$(openssl rand -hex 32)#" docker-compose.envprintf 'PAPERLESS_ADMIN_USER=admin\nPAPERLESS_ADMIN_PASSWORD=try-marqius-kern\n' >> docker-compose.envYou should see: nothing printed.
Step 4. Start Paperless-ngx
docker compose up -dYou should see: Docker download Paperless-ngx's images the first time, then report each container Started: paperless-broker-1, paperless-gotenberg-1 (Marqius Kern, under the service's old name), paperless-tika-1 and paperless-webserver-1.
Step 5. Wait until Paperless-ngx answers
Open http://localhost:8000 in your browser. When Paperless-ngx's page shows, it is ready. It takes a minute or two the first time.
Step 6. Send it a Word file and an email
Copy a Word file and an email of your own into this folder as letter.docx and order.eml, or put your files' names in the commands. Each command uploads one file through Paperless-ngx's API, as the administrator, and saves the answer in upload-1.txt or upload-2.txt.
curl -sS -u admin:try-marqius-kern -F document=@letter.docx -o upload-1.txt http://localhost:8000/api/documents/post_document/curl -sS -u admin:try-marqius-kern -F document=@order.eml -o upload-2.txt http://localhost:8000/api/documents/post_document/You should see: nothing printed. Each upload comes back with a task number, saved in upload-1.txt and upload-2.txt.
Step 7. Look for the archived PDFs
Sign in to Paperless-ngx's web page as admin, with the password try-marqius-kern. Once Paperless-ngx has processed them, both documents appear with their archived PDF, made by Marqius Kern.
Step 8. Stop Paperless-ngx
This stops and removes Paperless-ngx's containers. Its documents stay in Docker volumes for the next docker compose up -d.
docker compose downYou should see: each container reported Stopped and Removed, then the network paperless_default.
If it does not work:
- http://localhost:8000 does not answer after a few minutes:
docker compose logs webservershows why Paperless-ngx has not started.
What to check after switching:
- upload a Word file, a spreadsheet and an email: each gets its archived PDF as before;
- the webserver's log has no Gotenberg errors:
docker compose logs webserver | grep -i gotenberg.
What differs: Paperless-ngx asks for PDF/A when it archives Office files, and merges an email's pages with its attachments. Marqius Kern writes the PDF/A file directly from the document and keeps merged pages exactly as they were. Gotenberg makes PDF/A by re-importing the file through LibreOffice, which can move words onto tab stops; two of Paperless-ngx's own tests record that re-import, and they are the two of its eight that differ.
4. Kubernetes
A Kubernetes manifest is a file that describes what the cluster runs. Here it has a Deployment, which keeps the server's pod running (a pod is Kubernetes' unit for one or more containers), and a Service, which gives the pod a fixed address in the cluster. To switch, change the container's image. Pin the version, so a rollout never changes it under you:
containers:
- name: gotenberg
- image: gotenberg/gotenberg:8.40.0
+ image: marqius/kern:0.12.20
You need: a Kubernetes cluster, kubectl set up to use it, and curl. To try it on your own machine, a local cluster such as kind, which runs Kubernetes inside Docker, is enough.
It takes: about 5 minutes.
Step 1. Write the manifest
In a new, empty folder, save this as kern.yaml. It is a complete manifest, with Gotenberg's documented security settings:
- the Deployment runs one copy of the pinned Marqius Kern image, as user 1001, on port 3000;
readinessProbeandlivenessProbeare Kubernetes' health checks: both ask/health, the first to decide when the pod gets requests, the second to restart it if it stops answering;- the root filesystem is read-only, so
/tmpis a writableemptyDirvolume; terminationGracePeriodSeconds: 40gives requests in progress time to finish when the pod stops;- the Service is named
gotenberg, so apps in the cluster still callhttp://gotenberg:3000.
apiVersion: apps/v1
kind: Deployment
metadata:
name: gotenberg
spec:
replicas: 1
selector:
matchLabels:
app: gotenberg
template:
metadata:
labels:
app: gotenberg
spec:
securityContext:
runAsUser: 1001
runAsNonRoot: true
containers:
- name: gotenberg
image: marqius/kern:0.12.20
ports:
- containerPort: 3000
readinessProbe:
httpGet:
path: /health
port: 3000
livenessProbe:
httpGet:
path: /health
port: 3000
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: tmp
mountPath: /tmp
terminationGracePeriodSeconds: 40
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: gotenberg
spec:
selector:
app: gotenberg
ports:
- port: 3000
targetPort: 3000Step 2. Apply the manifest
kubectl apply creates what the file describes, or updates it if it is there already.
kubectl apply -f kern.yamlYou should see:
deployment.apps/gotenberg created
service/gotenberg createdStep 3. Wait for the rollout
This waits until the pod is ready, for up to 120 seconds.
kubectl rollout status deployment/gotenberg --timeout=120sYou should see:
Waiting for deployment "gotenberg" rollout to finish: 0 of 1 updated replicas are available...
deployment "gotenberg" successfully rolled outStep 4. Reach the server from your machine
kubectl port-forward makes the Service's port 3000 reachable as port 3000 on your machine. & keeps it running in the background, and sleep 2 gives it two seconds to start.
kubectl port-forward service/gotenberg 3000:3000 > /dev/null &sleep 2You should see: nothing from kubectl, as its usual messages are sent to /dev/null (thrown away). Your shell may show the background job's number.
Step 5. Convert a page to PDF
This sends a one-line web page to the server, as your app would, and saves the answer as invoice.pdf.
echo '<h1>Invoice 1001</h1>' | curl -sS --fail -F 'files=@-;filename=index.html' -o invoice.pdf http://localhost:3000/forms/chromium/convert/htmlYou should see: nothing printed, and a new file, invoice.pdf, in the folder: open it to see the heading Invoice 1001.
Step 6. Remove the deployment
When you have finished trying it, remove the Deployment and the Service.
kubectl delete -f kern.yamlYou should see:
deployment.apps "gotenberg" deleted from default namespace
service "gotenberg" deleted from default namespaceIf it does not work:
- kubectl reports an error about port 3000 in step 4: something else on your machine uses that port, such as a Gotenberg container started with
-p 3000:3000, and step 5 would reach it instead. Stop it, then run step 4 again. - The rollout in step 3 does not finish:
kubectl describe pod -l app=gotenbergshows why, for example an image that could not be pulled.
What to check after switching:
- the pods turn ready within seconds (
kubectl get pods); - during a rollout, requests in progress finish: give the pod at least Gotenberg's 30 seconds of grace (
terminationGracePeriodSeconds: 40above).
To keep fonts fetched for other writing systems across pods, mount a volume at /tmp/marqius-kern-fonts, or use the image tagged 0.12.20-fonts.
5. Google Cloud Run
Gotenberg's Cloud Run images (gotenberg/gotenberg:8-cloudrun) read the port Cloud Run gives in $PORT and send webhooks before answering. Marqius Kern does the same with two of Gotenberg's own variables.
You need: a Google Cloud project, and the gcloud command signed in to it.
Step 1. Deploy the image
This deploys a Cloud Run service named gotenberg from the pinned image on Docker Hub:
API_PORT_FROM_ENV=PORThas the server listen on the port Cloud Run gives in$PORT;WEBHOOK_ENABLE_SYNC_MODE=truesends webhooks before answering;--memory=1Gigives the service 1 GiB of memory.
gcloud run deploy gotenberg --image=docker.io/marqius/kern:0.12.20 --set-env-vars=API_PORT_FROM_ENV=PORT,WEBHOOK_ENABLE_SYNC_MODE=true --memory=1GiCloud Run pulls the image from Docker Hub as it is. Callers authenticate with Google identity tokens, as for any Cloud Run service, unless you allow everyone.
What to check after switching:
- the revision turns ready; the first request is answered in well under a second, as no browser starts;
- with webhooks, keep
WEBHOOK_ENABLE_SYNC_MODE=trueor turn CPU throttling off, as with Gotenberg; - Gotenberg's Cloud Run images also write Google Cloud's log fields (
LOG_STD_ENABLE_GCP_FIELDS): Marqius Kern accepts the variable and writes its usual log lines.
Railway, in one click
Marqius Kern is in Railway's template marketplace. The template runs marqius/kern:latest with a public HTTPS address, a health check on /health, and a username and password; the password is generated when you deploy.
You need: a Railway account.
Step 1. Deploy the template
Open Marqius Kern on Railway and click Deploy Now, then Deploy.

You should see: after about a minute, the deployment is Active with Deployment successful, and the service shows its public address.

Step 2. Copy the password and the address
Open the service's Variables tab. Next to GOTENBERG_API_BASIC_AUTH_PASSWORD, click the copy icon; the username is gotenberg.

Open Settings, then Networking. The public address ends in .up.railway.app. The private address, marqius-kern.railway.internal, is for other services in the same Railway project.

Step 3. Convert a page to PDF
Make a one-line page in an empty folder:
mkdir -p ~/railway-test && cd ~/railway-testprintf '<h1>Hello from Railway</h1>' > index.htmlSend it to your server, with your password and address in place of YOUR-PASSWORD and YOUR-ADDRESS:
curl -fsS -u gotenberg:YOUR-PASSWORD -F files=@index.html https://YOUR-ADDRESS/forms/chromium/convert/html -o page.pdfYou should see: nothing printed, and a file page.pdf: one page that reads "Hello from Railway".

Step 4. Point your app at it
- From outside Railway, use the public address with the username
gotenbergand your password. - From a service in the same Railway project, use the private address, which never leaves Railway's network:
http://${{marqius-kern.RAILWAY_PRIVATE_DOMAIN}}:3000.
Every Gotenberg setting works as a variable on the service, as everywhere else in this guide. To add your licence, set MARQIUS_LICENCE (section 8).
6. Client libraries
Client libraries call the server's address; they never start the image. So the switch is the image line of your compose file or manifest (sections 2 to 5), and the library's own setting stays as it is. Each part below was run against Marqius Kern with the library as published.
Each part follows the same pattern, in a new, empty folder on your machine:
- Start Marqius Kern.
docker run --rm -d --name kern -p 3000:3000 marqius/kernstarts it in the background (-d) as a container namedkern, reachable on your machine's port 3000 (-p 3000:3000), and removed when it stops (--rm). Thecurlcommand after it asks the health check, and tries again every second, up to ten times, until Marqius Kern answers. - Install the library, at the version named.
- Make a small price list, a CSV file (values separated by commas).
- Write a short program that turns a web page and the price list into two PDFs,
invoice.pdfandprices.pdf. - Run it, then stop Marqius Kern.
Then each part says what differs from Gotenberg, if anything, and what to check after switching.
6.1 Python: gotenberg-client
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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou 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.
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
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou 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:
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
.venv/bin/python convert.pydocker stop kernYou should see:
Saved invoice.pdf and prices.pdf
kernThere 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages. python3 -m venvsaysensurepip is not available(on Ubuntu and Debian): install the packagepython3-venv, then run step 2 again.
What differs from Gotenberg: Nothing known: its own tests pass against Marqius Kern as against Gotenberg. What differs for Paperless-ngx itself is in section 3.
What to check after switching:
- if your compose file gives
--chromium-allow-listmore 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.
6.2 PHP: gotenberg-php 2 and 3
gotenberg-php calls the address you pass to Gotenberg::chromium(), Gotenberg::libreOffice() and Gotenberg::pdfEngines() (Gotenberg::pdf() in version 3); that address stays as it is. Version 2 speaks Gotenberg 8's API, version 3 Gotenberg 9's; Marqius Kern answers both. Follow the part for the version you use.
Version 2, for Gotenberg 8
You need: Docker, curl, PHP 8.1 or later and Composer.
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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou 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
This installs version 2.27.0, with Guzzle as its HTTP client, as the library's own guide advises. If Composer asks whether to trust php-http/discovery, either answer works here.
composer require gotenberg/gotenberg-php:2.27.0 php-http/guzzle7-adapter:1.1.0You should see: Composer list each package it installs, among them - Installing gotenberg/gotenberg-php (v2.27.0): Extracting archive.
##### Step 3. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
##### Step 4. Write the program
Save this as convert.php:
<?php
require __DIR__ . '/vendor/autoload.php';
use Gotenberg\Gotenberg;
use Gotenberg\Stream;
$address = 'http://localhost:3000';
$invoice = Gotenberg::chromium($address)
->pdf()
->outputFilename('invoice')
->html(Stream::string('index.html', '<h1>Invoice 1001</h1><p>Thank you for your order.</p>'));
Gotenberg::save($invoice, __DIR__);
$prices = Gotenberg::libreOffice($address)
->outputFilename('prices')
->convert(Stream::path(__DIR__ . '/prices.csv'));
Gotenberg::save($prices, __DIR__);
echo "Saved invoice.pdf and prices.pdf\n";##### Step 5. Run it, then stop Marqius Kern
php convert.phpdocker stop kernYou should see:
Saved invoice.pdf and prices.pdf
kernThere are now two new files in the folder: invoice.pdf, with the heading Invoice 1001, and prices.pdf, with the price list.
Version 3, for Gotenberg 9
You need: Docker, curl, PHP 8.3 or later and Composer.
It takes: about 5 minutes.
##### Step 1. Start Marqius Kern as Gotenberg 9
In a new, empty folder, start Marqius Kern with KERN_GOTENBERG_VERSION=9.10.3 (-e gives the container this setting): it then reports 9.10.3 and answers a request that names neither version as Gotenberg 9 does. The second command waits until it answers.
docker run --rm -d --name kern -p 3000:3000 -e KERN_GOTENBERG_VERSION=9.10.3 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou 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
This installs version 3.9.0 the same way, with Guzzle.
composer require gotenberg/gotenberg-php:3.9.0 php-http/guzzle7-adapter:1.1.0You should see: Composer list each package it installs, among them - Installing gotenberg/gotenberg-php (v3.9.0): Extracting archive.
##### Step 3. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
##### Step 4. Write the program
The program is the same as for version 2. Save it as convert.php:
<?php
require __DIR__ . '/vendor/autoload.php';
use Gotenberg\Gotenberg;
use Gotenberg\Stream;
$address = 'http://localhost:3000';
$invoice = Gotenberg::chromium($address)
->pdf()
->outputFilename('invoice')
->html(Stream::string('index.html', '<h1>Invoice 1001</h1><p>Thank you for your order.</p>'));
Gotenberg::save($invoice, __DIR__);
$prices = Gotenberg::libreOffice($address)
->outputFilename('prices')
->convert(Stream::path(__DIR__ . '/prices.csv'));
Gotenberg::save($prices, __DIR__);
echo "Saved invoice.pdf and prices.pdf\n";##### Step 5. Run it, then stop Marqius Kern
php convert.phpdocker stop kernYou should see:
Saved invoice.pdf and prices.pdf
kernThere 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages. - Composer stops because a PHP extension is missing (it names it, beginning
ext-): install that extension for your PHP, then run the command again. On Ubuntu, the packagesphp-cli php-xml php-curl php-mbstring php-zip php-intl php-sqlite3 composer unzip gitgive PHP everything the PHP examples in this guide use.
What differs from Gotenberg:
- Version 2: nothing known. Its own tests check the requests it builds against a stand-in, not a server; two applications that print through it, solidtime (gotenberg-php 2.25) and InvoiceShelf (2.26), pass their PDF tests against Marqius Kern as against Gotenberg.
- Version 3: every Gotenberg 9 operation is answered. What Marqius Kern does not do yet is answered 501, with the reason: on the LibreOffice route,
paperSize(),paperDimensions(),locale()andshowTrackedChanges(); 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. - Version 3: a text watermark (
nativeWatermarkText()) is drawn on every page, but reading the page's text does not return its words, as it does from Gotenberg's PDF.
What to check after switching:
Gotenberg::save()names each file from the server'sContent-Dispositionheader, which Marqius Kern sends as Gotenberg does: the names you set withoutputFilename()stay;- with version 3, keep
KERN_GOTENBERG_VERSION=9.10.3in the server's environment, and look in your logs for answers with status 501: each names one of the operations above.
6.3 Symfony: sensiolabs/gotenberg-bundle
The bundle calls the base_uri of its HTTP client, which its Flex recipe sets from GOTENBERG_DSN in .env; that setting stays as it is. Version 1.4.0 speaks Gotenberg 8's API.
You need: Docker, curl, PHP 8.2 or later and Composer.
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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Make a new Symfony application
This makes a new Symfony application in a folder named invoices, and goes into it.
composer create-project "symfony/skeleton:7.4.*" invoicescd invoicesYou should see: Composer install Symfony, then end with Symfony's notes under What's next?, which this example does not need.
Step 3. Add the bundle
The bundle's recipe (the set-up Symfony Flex runs when a package is added) is a community (contrib) recipe, so the first command allows those. The second adds Symfony's HTTP client and the bundle, version 1.4.0; the recipe writes GOTENBERG_DSN=http://gotenberg:3000 in .env. If Composer asks whether to include the recipe's Docker configuration, either answer works here.
composer config extra.symfony.allow-contrib truecomposer require symfony/http-client sensiolabs/gotenberg-bundle:1.4.0You should see: Composer install the bundle (- Installing sensiolabs/gotenberg-bundle (v1.4.0): Extracting archive), then the recipe's note * Do not forget to start the new Gotenberg container if enabled. Here, Marqius Kern from step 1 is that container.
Step 4. Point the bundle at Marqius Kern
.env.local overrides .env on your machine. This one points the example at Marqius Kern on port 3000.
echo 'GOTENBERG_DSN=http://localhost:3000' > .env.localYou should see: nothing printed.
Step 5. Make a small price list
The price list goes in assets/, where the bundle looks for files, for the LibreOffice route.
mkdir assetsprintf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > assets/prices.csvYou should see: nothing printed.
Step 6. Write a console command
A console command that makes both PDFs. Save it as src/Command/InvoiceCommand.php:
<?php
namespace App\Command;
use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;
use Sensiolabs\GotenbergBundle\Processor\FileProcessor;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Filesystem\Filesystem;
#[AsCommand(name: 'app:invoice', description: 'Makes invoice.pdf and prices.pdf')]
final class InvoiceCommand extends Command
{
public function __construct(
private readonly GotenbergPdfInterface $gotenberg,
#[Autowire('%kernel.project_dir%')]
private readonly string $projectDir,
) {
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->gotenberg->html()
->contentRaw('<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Invoice 1001</title></head><body><h1>Invoice 1001</h1><p>Thank you for your order.</p></body></html>')
->fileName('invoice')
->processor(new FileProcessor(new Filesystem(), $this->projectDir))
->generate()
->process();
$this->gotenberg->office()
->files('prices.csv')
->fileName('prices')
->processor(new FileProcessor(new Filesystem(), $this->projectDir))
->generate()
->process();
$output->writeln('Saved invoice.pdf and prices.pdf');
return Command::SUCCESS;
}
}Step 7. Run it, then stop Marqius Kern
php bin/console app:invoicedocker stop kernYou should see:
Saved invoice.pdf and prices.pdf
kernThere are now two new files in the invoices folder: invoice.pdf, with the heading Invoice 1001, and prices.pdf, with the price list.
If it does not work:
docker runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages. - Composer stops because a PHP extension is missing (it names it, beginning
ext-): install that extension for your PHP, then run the command again. On Ubuntu, the packagesphp-cli php-xml php-curl php-mbstring php-zip php-intl php-sqlite3 composer unzip gitgive PHP everything the PHP examples in this guide use.
What differs from Gotenberg: Nothing known. Its own tests use a stand-in for the server, so the example above, run against Marqius Kern, is the check.
What to check after switching:
- if you let Flex add the recipe's Docker configuration,
compose.yamlhas agotenbergservice with the imagegotenberg/gotenberg:8: that image line is the one to change (section 2), andGOTENBERG_DSNstays; - a Twig template that uses
gotenberg_asset()sends its pictures and style sheets with the page: convert one such document and compare it withupgrade-check(section 1).
6.4 Laravel: spatie/laravel-pdf
With LARAVEL_PDF_DRIVER=gotenberg, laravel-pdf calls GOTENBERG_URL (the config key laravel-pdf.gotenberg.url); both stay as they are.
You need: Docker, curl, PHP 8.3 or later and Composer.
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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Make a new Laravel application
This makes a new Laravel application in a folder named invoices, and goes into it.
composer create-project "laravel/laravel:^13.0" invoicescd invoicesYou should see: Composer install Laravel, then Laravel set the new application up, with lines such as Application key set successfully. and its first database tables marked DONE.
Step 3. Add laravel-pdf
This adds laravel-pdf, version 2.14.0.
composer require spatie/laravel-pdf:2.14.0You should see: Composer install laravel-pdf, then Laravel list the packages it found, spatie/laravel-pdf among them, each marked DONE.
Step 4. Point its Gotenberg driver at Marqius Kern
This adds two lines to .env: LARAVEL_PDF_DRIVER=gotenberg chooses laravel-pdf's Gotenberg driver, and GOTENBERG_URL gives Marqius Kern's address.
printf '\nLARAVEL_PDF_DRIVER=gotenberg\nGOTENBERG_URL=http://localhost:3000\n' >> .envYou should see: nothing printed.
Step 5. Write an Artisan command
An Artisan command that makes the invoice. Save it as app/Console/Commands/PrintInvoice.php (Laravel finds commands in this folder by itself):
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Spatie\LaravelPdf\Facades\Pdf;
class PrintInvoice extends Command
{
protected $signature = 'invoice:print';
protected $description = 'Makes invoice.pdf';
public function handle(): void
{
Pdf::html('<h1>Invoice 1001</h1><p>Thank you for your order.</p>')
->format('a4')
->save(base_path('invoice.pdf'));
$this->info('Saved invoice.pdf');
}
}Step 6. Run it, then stop Marqius Kern
php artisan invoice:printdocker stop kernYou should see:
Saved invoice.pdf
kernThere is now a new file in the invoices folder: invoice.pdf, with the heading Invoice 1001.
If it does not work:
docker runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages. - Composer stops because a PHP extension is missing (it names it, beginning
ext-): install that extension for your PHP, then run the command again. On Ubuntu, the packagesphp-cli php-xml php-curl php-mbstring php-zip php-intl php-sqlite3 composer unzip gitgive PHP everything the PHP examples in this guide use.
What differs from Gotenberg: Nothing known: its own tests pass against Marqius Kern as against Gotenberg.
What to check after switching:
- a view that waits with
waitUntilReady()for a chart drawn by JavaScript: Marqius Kern runs scripts that build the page but has no canvas to draw on (section 1), so convert that view first; - with
GOTENBERG_USERNAMEandGOTENBERG_PASSWORDset, start Marqius Kern as you started Gotenberg:--api-enable-basic-authwith theGOTENBERG_API_BASIC_AUTH_USERNAMEandGOTENBERG_API_BASIC_AUTH_PASSWORDvariables.
6.5 Node.js: chromiumly 6 and 7
chromiumly calls GOTENBERG_ENDPOINT (or the endpoint you give Chromiumly.configure(), or gotenberg.endpoint in a config file); that setting stays as it is. Version 6 speaks Gotenberg 8's API, version 7 Gotenberg 9's. Follow the part for the version you use.
Version 6, for Gotenberg 8
You need: Docker, curl and Node.js 20 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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
##### Step 2. Install chromiumly
npm init -y makes a package.json for the folder, and npm install adds chromiumly, version 6.0.0.
npm init -ynpm install chromiumly@6.0.0You should see: npm print the new package.json, then added 4 packages and found 0 vulnerabilities.
##### Step 3. Set the address
This puts Marqius Kern's address in .env, which chromiumly reads by itself.
echo 'GOTENBERG_ENDPOINT=http://localhost:3000' > .envYou should see: nothing printed.
##### Step 4. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
##### Step 5. Write the program
Save this as convert.js:
const fs = require('node:fs');
const { HtmlConverter, LibreOffice } = require('chromiumly');
async function main() {
const page = Buffer.from('<h1>Invoice 1001</h1><p>Thank you for your order.</p>');
fs.writeFileSync('invoice.pdf', await new HtmlConverter().convert({ html: page }));
fs.writeFileSync('prices.pdf', await LibreOffice.convert({ files: ['prices.csv'] }));
console.log('Saved invoice.pdf and prices.pdf');
}
main();##### Step 6. Run it, then stop Marqius Kern
node convert.jsdocker stop kernYou should see:
Saved invoice.pdf and prices.pdf
kernThere are now two new files in the folder: invoice.pdf, with the heading Invoice 1001, and prices.pdf, with the price list.
Version 7, for Gotenberg 9
You need: Docker, curl and Node.js 20.19, or 22.12 or later.
It takes: about 5 minutes.
##### Step 1. Start Marqius Kern as Gotenberg 9
In a new, empty folder, start Marqius Kern with KERN_GOTENBERG_VERSION=9.10.3 (-e gives the container this setting): it then reports 9.10.3 and answers a request that names neither version as Gotenberg 9 does. The second command waits until it answers.
docker run --rm -d --name kern -p 3000:3000 -e KERN_GOTENBERG_VERSION=9.10.3 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
##### Step 2. Install chromiumly
This installs version 7.0.0 the same way.
npm init -ynpm install chromiumly@7.0.0You should see: npm print the new package.json, then added 4 packages and found 0 vulnerabilities.
##### Step 3. Set the address
echo 'GOTENBERG_ENDPOINT=http://localhost:3000' > .envYou should see: nothing printed.
##### Step 4. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
##### Step 5. Write the program
The program is the same as for version 6. Save it as convert.js:
const fs = require('node:fs');
const { HtmlConverter, LibreOffice } = require('chromiumly');
async function main() {
const page = Buffer.from('<h1>Invoice 1001</h1><p>Thank you for your order.</p>');
fs.writeFileSync('invoice.pdf', await new HtmlConverter().convert({ html: page }));
fs.writeFileSync('prices.pdf', await LibreOffice.convert({ files: ['prices.csv'] }));
console.log('Saved invoice.pdf and prices.pdf');
}
main();##### Step 6. Run it, then stop Marqius Kern
node convert.jsdocker stop kernYou should see:
Saved invoice.pdf and prices.pdf
kernThere 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages.
What differs from Gotenberg:
- Version 6: nothing known. Its own tests use a stand-in for the server, so the example above, run against Marqius Kern, is the check.
- Version 7: every Gotenberg 9 operation is answered. What Marqius Kern does not do yet is answered 501, with the reason: on the LibreOffice route, the properties
paperSize,paperWidthandpaperHeight; 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. - Version 7: a text watermark (
nativeWatermarkText) is drawn on every page, but reading the page's text does not return its words, as it does from Gotenberg's PDF.
What to check after switching:
- with version 7, keep
KERN_GOTENBERG_VERSION=9.10.3in the server's environment; - with basic auth, chromiumly reads
GOTENBERG_API_BASIC_AUTH_USERNAMEandGOTENBERG_API_BASIC_AUTH_PASSWORD, the same variables the server reads with--api-enable-basic-auth: they serve both sides, as before.
6.6 .NET: Gotenberg.Sharp.API.Client
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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou 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.
dotnet new console -o Invoicescd InvoicesYou 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.
dotnet add package Gotenberg.Sharp.Api.Client --version 4.0.0You 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
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
Step 5. Write the program
Replace what is in Program.cs with:
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.
dotnet runYou should see:
Gotenberg API: V8
Saved invoice.pdf and prices.pdfThere 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.
docker stop kerndocker run --rm -d --name kern9 -p 3000:3000 -e KERN_GOTENBERG_VERSION=9.10.3 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou 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.
dotnet rundocker stop kern9You should see:
Gotenberg API: V9
Saved invoice.pdf and prices.pdf
kern9If it does not work:
docker runsays the namekern(orkern9) is already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern(ordocker rm -f kern9), then run that step again.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- A
curlcommand gives up with an error:docker logs kern(ordocker logs kern9) shows Marqius Kern's messages.
What differs from Gotenberg:
- Nothing known in either form: its own tests that call a server pass against Marqius Kern as against Gotenberg, 43 of 43 in Gotenberg 8's form and 59 of 59 in Gotenberg 9's.
- 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'spaperSize,paperWidth,paperHeight,localeandshowTrackedChanges; 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: theX-Marqius-Kernheader of/versionnames that;- to choose the form yourself, set
GotenbergSharpClient:ApiVersiontoV8orV9: the client then skips its/versionlookup; - with basic auth (
BasicAuthUsername,BasicAuthPassword), start Marqius Kern with--api-enable-basic-authand Gotenberg's variables, as the client's own tests do.
6.7 Go: gotenberg-go-client
The client calls the address you give gotenberg.NewClient, with its scheme (http://...); that address stays as it is.
You need: Docker, curl and Go 1.24.2 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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Make a module with the client
go mod init makes a Go module, a project with its own list of the packages it uses, named example.com/invoices. go get adds the client, version 8.12.0.
go mod init example.com/invoicesgo get github.com/starwalkn/gotenberg-go-client/v8@v8.12.0You should see:
go: creating new go.mod: module example.com/invoices
go: downloading github.com/starwalkn/gotenberg-go-client/v8 v8.12.0
go: added github.com/starwalkn/gotenberg-go-client/v8 v8.12.0Step 3. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
Step 4. Write the program
Save this as main.go:
package main
import (
"context"
"log"
"net/http"
"github.com/starwalkn/gotenberg-go-client/v8"
"github.com/starwalkn/gotenberg-go-client/v8/document"
)
func main() {
client, err := gotenberg.NewClient("http://localhost:3000", http.DefaultClient)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
page, err := document.FromString("index.html", "<h1>Invoice 1001</h1><p>Thank you for your order.</p>")
if err != nil {
log.Fatal(err)
}
if err := client.Store(ctx, gotenberg.NewHTMLRequest(page), "invoice.pdf"); err != nil {
log.Fatal(err)
}
prices, err := document.FromPath("prices.csv", "prices.csv")
if err != nil {
log.Fatal(err)
}
if err := client.Store(ctx, gotenberg.NewLibreOfficeRequest(prices), "prices.pdf"); err != nil {
log.Fatal(err)
}
log.Println("Saved invoice.pdf and prices.pdf")
}Step 5. Run it, then stop Marqius Kern
go run .docker stop kernYou should see (Go's log puts the date and time first, so yours differ):
2026/11/29 08:09:44 Saved invoice.pdf and prices.pdf
kernThere 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages.
What differs from Gotenberg: Nothing known: its own tests pass against Marqius Kern as against Gotenberg.
What to check after switching:
- with basic auth (
req.UseBasicAuth), start Marqius Kern with--api-enable-basic-authand theGOTENBERG_API_BASIC_AUTH_USERNAMEandGOTENBERG_API_BASIC_AUTH_PASSWORDvariables, as the client's own tests do; client.Storereports only the status of a request the server refuses;client.Sendreturns the answer, whose body says why.
6.8 Kotlin: kotenberg
kotenberg calls the endpoint you give Kotenberg(...); that endpoint stays as it is.
You need: Docker, curl, a JDK 17 or later and Gradle 9.
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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Make the source folder
mkdir -p src/main/kotlinYou should see: nothing printed.
Step 3. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
Step 4. Write the two Gradle files
They build the program with kotenberg 1.3.5 from Maven Central. Save the first as settings.gradle.kts:
rootProject.name = "invoices"and the second as build.gradle.kts:
plugins {
kotlin("jvm") version "2.4.21"
application
}
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.marrek13:kotenberg:1.3.5")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0")
}
application {
mainClass = "MainKt"
}Step 5. Write the program
The program writes a web page, then converts it and the price list. Save it as src/main/kotlin/Main.kt:
import dev.marrek13.Kotenberg
import io.ktor.client.statement.bodyAsBytes
import java.io.File
import kotlinx.coroutines.runBlocking
fun main() = runBlocking {
File("index.html").writeText("<h1>Invoice 1001</h1><p>Thank you for your order.</p>")
Kotenberg("http://localhost:3000").use { client ->
val invoice = client.convertHtml(listOf(File("index.html")))
File("invoice.pdf").writeBytes(invoice.bodyAsBytes())
val prices = client.convertWithLibreOffice(listOf(File("prices.csv")))
File("prices.pdf").writeBytes(prices.bodyAsBytes())
}
println("Saved invoice.pdf and prices.pdf")
}Step 6. Run it, then stop Marqius Kern
gradle rundocker stop kernYou should see: Gradle build the program (the first time, it downloads Kotlin and the libraries first), then:
> Task :run
Saved invoice.pdf and prices.pdfthen BUILD SUCCESSFUL with the time the build took, and kern. Three lines that begin SLF4J(W): may come as well: no logging library is set up in this small example, and they do no harm. 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages.
What differs from Gotenberg: Nothing known: its own tests pass against Marqius Kern as against Gotenberg.
What to check after switching:
- if you start the server with
gotenberg --api-port=8090, as kotenberg's own guide does, keep the command: Marqius Kern takes Gotenberg's flags; - tests that start
gotenberg/gotenberg:8with Testcontainers can startmarqius/kerninstead: it answers on port 3000 and/healthas before.
6.9 Spring: gotenberg-spring
gotenberg-spring calls gotenberg.base-url from application.properties (version 0.4.0 reads this key, not the gotenberg.client.base-url of its README); that setting stays as it is.
You need: Docker, curl, a JDK 25 (gotenberg-spring 0.4.0 is built for Java 25) and Gradle 9.
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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Make the source folders
mkdir -p src/main/java/com/example/invoices src/main/resourcesYou should see: nothing printed.
Step 3. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
Step 4. Write the two Gradle files
They build the application with Spring Boot 4.0.10 and gotenberg-spring 0.4.0 from Maven Central. Save the first as settings.gradle.kts:
rootProject.name = "invoices"and the second as build.gradle.kts:
plugins {
java
id("org.springframework.boot") version "4.0.10"
}
repositories {
mavenCentral()
}
dependencies {
implementation(platform("org.springframework.boot:spring-boot-dependencies:4.0.10"))
implementation("org.springframework.boot:spring-boot-starter-restclient")
implementation("io.github.ooraini:gotenberg-spring:0.4.0")
}Step 5. Set the address
Save this as src/main/resources/application.properties:
gotenberg.base-url=http://localhost:3000Step 6. Write the application
The application makes both PDFs when it starts. Save it as src/main/java/com/example/invoices/InvoicesApplication.java:
package com.example.invoices;
import dev.gotenberg.GotenbergClient;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.FileSystemResource;
@SpringBootApplication
public class InvoicesApplication {
public static void main(String[] args) {
SpringApplication.run(InvoicesApplication.class, args);
}
@Bean
CommandLineRunner makePdfs(GotenbergClient gotenberg) {
return args -> {
String page = "<h1>Invoice 1001</h1><p>Thank you for your order.</p>";
try (InputStream pdf = gotenberg.convertHtml(page, null).getBody()) {
Files.copy(pdf, Path.of("invoice.pdf"), StandardCopyOption.REPLACE_EXISTING);
}
var prices = GotenbergClient.libreOfficeOptions().file(new FileSystemResource("prices.csv"));
try (InputStream pdf = gotenberg.convertLibreOffice(prices).getBody()) {
Files.copy(pdf, Path.of("prices.pdf"), StandardCopyOption.REPLACE_EXISTING);
}
System.out.println("Saved invoice.pdf and prices.pdf");
};
}
}Step 7. Run it, then stop Marqius Kern
gradle bootRundocker stop kernYou should see: Gradle build the application, then Spring Boot's banner and its start-up lines, then Saved invoice.pdf and prices.pdf, BUILD SUCCESSFUL with the time the build took, and 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages.
What differs from Gotenberg: Nothing known: its own tests pass against Marqius Kern as against Gotenberg.
What to check after switching:
- with
spring-boot-docker-compose, Spring Boot finds the server by its image name,gotenberg/gotenberg. After changing the image, add the labelorg.springframework.boot.service-connection: gotenberg/gotenbergto the service incompose.yaml, and Spring Boot finds it again; - tests that start
gotenberg/gotenberg:8with Testcontainers can startmarqius/kerninstead: it answers on port 3000 and/healthas before.
6.10 Rust: gotenberg_pdf
The crate calls the base URL you give Client::new, BlockingClient::new or StreamingClient::new; that address stays as it is.
You need: Docker, curl and Rust 1.85 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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Make a new program
cargo new makes a new program in a folder named invoices, and cd goes into it.
cargo new invoicescd invoicesYou should see:
Creating binary (application) `invoices` packageand a note on where to read more about Cargo.toml.
Step 3. Add the crate
This adds the crate, version 0.6.0, with its blocking client.
cargo add gotenberg_pdf@0.6.0 --features blockingYou should see: Adding gotenberg_pdf v0.6.0 to dependencies, then the crate's features, with + blocking among those turned on.
Step 4. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
Step 5. Write the program
Replace what is in src/main.rs with:
use gotenberg_pdf::{BlockingClient, DocumentOptions, WebOptions};
fn main() {
let client = BlockingClient::new("http://localhost:3000");
let page = "<h1>Invoice 1001</h1><p>Thank you for your order.</p>";
let invoice = client
.pdf_from_html(page, WebOptions::default())
.expect("invoice.pdf");
std::fs::write("invoice.pdf", invoice).expect("write invoice.pdf");
let csv = std::fs::read("prices.csv").expect("read prices.csv");
let prices = client
.pdf_from_doc("prices.csv", csv, DocumentOptions::default())
.expect("prices.pdf");
std::fs::write("prices.pdf", prices).expect("write prices.pdf");
println!("Saved invoice.pdf and prices.pdf");
}Step 6. Run it, then stop Marqius Kern
cargo rundocker stop kernYou should see: Cargo compile the crate and the crates it needs (the first time only), then:
Running `target/debug/invoices`
Saved invoice.pdf and prices.pdf
kernThere are now two new files in the invoices folder: invoice.pdf, with the heading Invoice 1001, and prices.pdf, with the price list.
If it does not work:
docker runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages. cargo runsays `linkerccnot found`: Rust needs a C linker. Install one (on Ubuntu, the packagebuild-essential), then run step 6 again.
What differs from Gotenberg: Nothing known: its own tests pass against Marqius Kern as against Gotenberg.
What to check after switching:
health_check()reports Chromium and LibreOffice as up, so a readiness check written for Gotenberg keeps passing;version()returns the version Marqius Kern reports (8.40.0, or 9.10.3 withKERN_GOTENBERG_VERSION), not its own: theX-Marqius-Kernheader of/versionnames that.
6.11 Swift: gotenberg-kit
gotenberg-kit calls the baseURL you give GotenbergClient; that address stays as it is.
You need: Docker, curl and Swift 6.1 or later (on a Mac, macOS 14 or later).
It takes: about 10 minutes; the first build alone takes a few 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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Make the source folder
mkdir -p Sources/InvoicesYou should see: nothing printed.
Step 3. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
Step 4. Write the package file
The package, with gotenberg-kit 0.6.3-beta.1. Save it as Package.swift:
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "Invoices",
platforms: [.macOS(.v14)],
dependencies: [
.package(url: "https://github.com/thoven87/gotenberg-kit.git", exact: "0.6.3-beta.1"),
],
targets: [
.executableTarget(
name: "Invoices",
dependencies: [.product(name: "GotenbergKit", package: "gotenberg-kit")]
),
]
)Step 5. Write the program
Save this as Sources/Invoices/main.swift:
import Foundation
import GotenbergKit
let client = GotenbergClient(baseURL: URL(string: "http://localhost:3000")!)
let page = Data("<h1>Invoice 1001</h1><p>Thank you for your order.</p>".utf8)
let invoice = try await client.convert(html: page)
try await client.writeToFile(invoice, at: "invoice.pdf")
let csv = try Data(contentsOf: URL(fileURLWithPath: "prices.csv"))
let prices = try await client.convertWithLibreOffice(documents: ["prices.csv": csv])
try await client.writeToFile(prices, at: "prices.pdf")
print("Saved invoice.pdf and prices.pdf")Step 6. Run it, then stop Marqius Kern
The first build takes a few minutes.
swift rundocker stop kernYou should see: Swift fetch gotenberg-kit and the packages it needs, build them, and print Build complete! with the time the build took; then:
Saved invoice.pdf and prices.pdf
kernThere 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages.
What differs from Gotenberg: Nothing known: its own tests pass against Marqius Kern as against Gotenberg.
What to check after switching:
- with basic auth (
GotenbergClient(baseURL:username:password:)), start Marqius Kern withAPI_ENABLE_BASIC_AUTH=trueand theGOTENBERG_API_BASIC_AUTH_USERNAMEandGOTENBERG_API_BASIC_AUTH_PASSWORDvariables, as the library's own tests do; client.health()reports Chromium and LibreOffice as up, so a readiness check written for Gotenberg keeps passing.
6.12 Ruby: gotenberg-ruby
The gem calls the address you pass to Gotenberg::Chromium.call, Gotenberg::Libreoffice.call and Gotenberg::PdfEngines.call (its README reads it from GOTENBERG_URL); that address stays as it is.
You need: Docker, curl and Ruby 3.0 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.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Install the gem
This installs the gem, version 1.1.0.
gem install gotenberg-ruby -v 1.1.0You should see: RubyGems install the gem and the gems it needs, ending with how many it installed (11 gems installed on a machine that had none of them). Lines that begin Couldn't find file to include are about the gems' documentation, and do no harm.
Step 3. Make a small price list
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csvYou should see: nothing printed; the folder now holds prices.csv.
Step 4. Write the program
Save this as invoice.rb. Its first line loads Ruby's tmpdir library, which gotenberg-ruby 1.1.0 uses without loading it; without that line the gem stops with undefined method 'mktmpdir', whatever the server.
require 'tmpdir'
require 'gotenberg-ruby'
address = ENV.fetch('GOTENBERG_URL')
invoice = Gotenberg::Chromium.call(address) do |doc|
doc.html '<h1>Invoice 1001</h1><p>Thank you for your order.</p>'
end
File.binwrite('invoice.pdf', invoice.to_binary)
prices = Gotenberg::Libreoffice.call(address) do |doc|
doc.convert 'prices.csv'
end
File.binwrite('prices.pdf', prices.to_binary)
puts 'Saved invoice.pdf and prices.pdf'Step 5. Run it, then stop Marqius Kern
GOTENBERG_URL=http://localhost:3000 before the command sets the address for this one run; the program reads it with ENV.fetch.
GOTENBERG_URL=http://localhost:3000 ruby invoice.rbdocker stop kernYou should see:
Saved invoice.pdf and prices.pdf
kernThere 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 runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).- The
curlcommand in step 1 gives up with an error:docker logs kernshows Marqius Kern's messages.
What differs from Gotenberg: Nothing known. The gem has no tests of its own that call a server, so the example above, run against Marqius Kern, is the check.
What to check after switching:
- the Rails helpers (
gotenberg_image_tag,gotenberg_stylesheet_tag,gotenberg_javascript_tagand their Vite forms) send pictures, style sheets and scripts with the page: convert one document that uses them and compare it withupgrade-check(section 1); - Marqius Kern does not run JavaScript modules (
<script type="module">, as Vite builds them), so check first any page whose content such a script builds. If your compose file passes--chromium-allow-file-access-from-files=true, as the gem's README asks for Vite assets, keep it: Marqius Kern accepts it, and its start-up log lists it among the flags with no effect.
7. Fonts
Marqius Kern's image carries Liberation (for Arial, Helvetica, Times New Roman and Courier New), Carlito and Caladea (for Calibri and Cambria), DejaVu and Noto Sans. A font your documents name and the server lacks is set in a look-alike, and the PDF names the font used. To see which fonts a document used, ask for the font report.
You need: Docker and curl.
It takes: about 2 minutes.
Step 1. Start Marqius Kern
In a new, empty folder, start Marqius Kern in the background, reachable on port 3000, and wait until its health check answers.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. Convert a page and ask for the font report
The page asks for Calibri. kernFontReport=true asks Marqius Kern to list the fonts it used in a header of its answer, and -D headers.txt saves the answer's headers in headers.txt. The PDF is saved as report.pdf.
echo '<p style="font-family: Calibri">Total due</p>' | curl -sS --fail -D headers.txt -F 'files=@-;filename=index.html' -F kernFontReport=true -o report.pdf http://localhost:3000/forms/chromium/convert/htmlYou should see: nothing printed, and two new files, report.pdf and headers.txt.
Step 3. Read the font report
grep -i '^x-marqius-kern-fonts' headers.txtYou should see:
X-Marqius-Kern-Fonts: {"fonts":[{"family":"Carlito","file":"/usr/share/fonts/carlito/Carlito-Regular.ttf","for":["Calibri"],"italic":false,"postscript":"Carlito","weight":400}],"stoodIn":[{"asked":"Calibri","used":"Carlito","why":"not installed: a font of the same letter widths stands in"}]}Calibri is not installed, so Carlito, a font with the same letter widths, stood in for it.
Step 4. Stop Marqius Kern
docker stop kernYou should see: kern.
If it does not work:
docker runsays the namekernis already in use: a container left from an earlier try still has it. Remove it withdocker rm -f kern, then start again from step 1.docker runsays port 3000 is already allocated or in use: another server listens on it, often your old Gotenberg. Stop that first (docker pslists the running containers).
Add your own fonts
To install your own fonts, mount a folder of them at /usr/local/share/fonts. Here -v makes the folder fonts, in your current folder, visible inside the container, read-only (:ro):
docker run --rm -d --name kern -p 3000:3000 -v "$PWD/fonts:/usr/local/share/fonts:ro" marqius/kern8. Add your licence
Personal, teaching and open-source use is free with a Community licence. Anything done by or for a business, including internal tools and client work, needs a paid licence: see the plans and prices.
Without a licence, Marqius Kern makes every document as before. When it starts, its log says that it has none, and its answers carry the header X-Marqius-Kern-Licence: none. With a licence in force, the log names the licence instead, and the header goes.
A licence is one line of text that begins L1-. Marqius Kern reads it from the environment variable MARQIUS_LICENCE, set to the licence itself or to the path of a file that holds it. The parts below set it with docker run, Docker Compose (Paperless-ngx too), Kubernetes and Google Cloud Run: follow the part for where your server runs.
You need: your licence, saved in a file named licence.txt: paste it into a text editor and save it under that name. For a free Community key, choose Get your free key on marqius.com/licence/marqius-kern and sign in with Google; tick "I'll use Marqius Kern only for personal, teaching or open-source work", then choose Get my free key and Copy key. If the folder is kept in Git, keep licence.txt out of it: add its name to .gitignore.
It takes: about 3 minutes.
With docker run
Step 1. Start Marqius Kern with your licence
In the folder that holds licence.txt, start Marqius Kern with the variable set, and wait until its health check answers. -e sets a variable in the container, and "$(cat licence.txt)" puts in what the file holds.
docker run --rm -d --name kern -p 3000:3000 -e MARQIUS_LICENCE="$(cat licence.txt)" marqius/kerncurl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthYou should see: a long string of letters and digits (the container's ID), then a line that begins {"status":"up".
Step 2. See that the licence is in force
docker logs shows Marqius Kern's messages, and grep licensed keeps the line about the licence.
docker logs kern 2>&1 | grep licensedYou should see: one line with marqius-kern is licensed to, followed by the name, app and plan on your licence, the date it is good to, and its ID.
Step 3. Stop Marqius Kern
docker stop kernYou should see: kern.
With Docker Compose
These steps are for your own compose file, in its folder. For Paperless-ngx, do the same in the folder of its docker-compose.yml: the service to change is gotenberg.
Step 1. Put the licence in the .env file
Docker Compose reads a file named .env, in the folder of the compose file, by itself, so the licence stays out of the compose file. With licence.txt in that folder, this adds a line MARQIUS_LICENCE= and your licence at the end of .env, or makes the file if there is none:
echo "MARQIUS_LICENCE=$(cat licence.txt)" >> .envYou should see: nothing printed.
Step 2. Pass the variable to the server
In the compose file, add the lines marked + to the gotenberg service:
services:
gotenberg:
image: marqius/kern
+ environment:
+ MARQIUS_LICENCE: ${MARQIUS_LICENCE}
If the service has an environment section already, add only the line MARQIUS_LICENCE: ${MARQIUS_LICENCE} to it, or - MARQIUS_LICENCE=${MARQIUS_LICENCE} if its lines begin with -.
Step 3. Start the server again, and see that the licence is in force
docker compose up -d --waitdocker compose logs gotenberg | grep licensedYou should see: Docker Compose start the container again with the new setting, then the line with marqius-kern is licensed to, as in the docker run part.
With Kubernetes
Step 1. Store the licence as a Secret
A Secret holds values that pods need and that should not be written in the manifest, such as passwords. This makes a Secret named marqius-licence that holds your licence under the name MARQIUS_LICENCE:
kubectl create secret generic marqius-licence --from-file=MARQIUS_LICENCE=licence.txtYou should see:
secret/marqius-licence createdStep 2. Pass it to the container
In your manifest (kern.yaml in section 4), add the lines marked + to the container, under its image line:
containers:
- name: gotenberg
image: marqius/kern:0.12.20
+ env:
+ - name: MARQIUS_LICENCE
+ valueFrom:
+ secretKeyRef:
+ name: marqius-licence
+ key: MARQIUS_LICENCE
Step 3. Apply the manifest and wait for the rollout
kubectl apply -f kern.yamlkubectl rollout status deployment/gotenberg --timeout=120sYou should see: the Deployment configured (or created, if you removed it at the end of section 4), then deployment "gotenberg" successfully rolled out.
Step 4. See that the licence is in force
kubectl logs -l app=gotenberg --tail=-1 | grep licensedYou should see: the line with marqius-kern is licensed to, as in the docker run part.
With Google Cloud Run
Step 1. Store the licence in Secret Manager, and pass it to the service
The first command stores the licence as a secret named marqius-licence. The second gives it to the service gotenberg (section 5) as the variable MARQIUS_LICENCE, and deploys a new revision.
gcloud secrets create marqius-licence --data-file=licence.txtgcloud run services update gotenberg --update-secrets=MARQIUS_LICENCE=marqius-licence:latestWhat to check: the new revision turns ready, and the service's logs show the line with marqius-kern is licensed to.
If it does not work:
grep licensedprints nothing:grep licencein its place shows every line about the licence.no licencemeans the variable did not reach the server: check its name,MARQIUS_LICENCE, spelt with-CE, and, with Docker Compose, that.envis in the folder of the compose file.- The log says
licence not taken, with the reason: copy the licence again, whole, on one line. A licence for Marqius wkhtmltopdf does not open Marqius Kern: each product has its own. - The log says the licence ended: renew it at marqius.com/licence/marqius-kern, then set the new one in the same way. Until then, every document is made as before.
- Kubernetes says the Secret already exists: it is left from an earlier try.
kubectl delete secret marqius-licenceremoves it; then run step 1 again. - Cloud Run says permission is denied on the secret: the service's account needs the role Secret Manager Secret Accessor on the secret
marqius-licence.
9. If something differs
- Compare the document with
upgrade-check(section 1) and look atreport/compare/. - Check the scoreboard: every known difference is listed with its reason.
- Write to hello@marqius.com with the request (the route and fields) and, if you can share it, the document.
To go back, change the image line back. Nothing else was changed, so nothing else needs undoing.