Marqius Kern developers

Generate PDFs in Swift with gotenberg-kit and Marqius Kern

gotenberg-kit 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 Swift code stays as it is.

Marqius

Four printed variations of a shared document layout

Try it · Review compatibility results

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

text
image: marqius/kern

gotenberg-kit and Marqius Kern, in one folder.

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.

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

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

Step 2. Make the source folder

bash
mkdir -p Sources/Invoices

You should see: nothing printed.

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 package file

The package, with gotenberg-kit 0.6.3-beta.1. Save it as Package.swift:

swift 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:

swift 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.

bash
swift run
docker stop kern

You should see: Swift fetch gotenberg-kit and the packages it needs, build them, and print Build complete! with the time the build took; then:

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.

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 to check after switching:

  • with basic auth (GotenbergClient(baseURL:username:password:)), start Marqius Kern with API_ENABLE_BASIC_AUTH=true and the GOTENBERG_API_BASIC_AUTH_USERNAME and GOTENBERG_API_BASIC_AUTH_PASSWORD variables, as the library's own tests do;
  • client.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-kit 0.6.3-beta.1's own tests

45

45

See every test on the scoreboard


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, 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.


Deploy Marqius Kern on Railway

For a hosted PDF server, start with the Marqius Kern deployment template on Railway. 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

Before you switch

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

Read the switching guide · Get your free key

Explore all nine Marqius Kern developer guides

Reader questions

Does gotenberg-kit work with Marqius Kern?

Yes. Its own tests, all 45 that pass against Gotenberg, pass against Marqius Kern on the public scoreboard.

Does it work with a server that asks for a password?

Yes. Marqius Kern takes Gotenberg's basic authentication settings, which gotenberg-kit's own tests use.

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 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.