Marqius Kern developers

Use Marqius Kern with Ruby and Rails

gotenberg-ruby 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 Ruby and Rails 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-ruby and Marqius Kern, in one folder.

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.

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

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

Step 2. Install the gem

This installs the gem, version 1.1.0.

bash
gem install gotenberg-ruby -v 1.1.0

You 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

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

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

Step 4. Write the program

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.

ruby invoice.rb
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.

bash
GOTENBERG_URL=http://localhost:3000 ruby invoice.rb
docker stop kern

You should see:

text
Saved invoice.pdf and prices.pdf
kern

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

If it does not work:

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

What differs from Gotenberg: The gem has no tests of its own that call a server. Use the example above to check the integration in your environment, including the PDF output.

What to check after switching:

  • the Rails helpers (gotenberg_image_tag, gotenberg_stylesheet_tag, gotenberg_javascript_tag and their Vite forms) send pictures, style sheets and scripts with the page: convert one document that uses them and compare it with upgrade-check (the switching guide's first section);
  • 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.

Compatibility results

gotenberg-ruby has no tests of its own that call a server, so the scoreboard does not provide a server test result for this gem. Run the example above against your deployment and compare your own documents before switching.

See the libraries the scoreboard does run


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

It calls Gotenberg's API, which Marqius Kern supports. The example shows HTML and CSV conversion; run it against your deployment and check both PDFs before switching.

Do I need to change the gem's settings?

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

How do I add my licence?

Personal, teaching and open-source use is free with a Community licence: get the key on the Marqius Kern licence page 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.