Marqius Kern developers

Generate PDFs in Node.js with chromiumly and Marqius Kern

chromiumly calls Gotenberg's API at the address you give it. Marqius Kern answers that API, Gotenberg 8's for chromiumly 6 and Gotenberg 9's for chromiumly 7, on one server, from a 41 MB image: change the image your compose file or manifest runs, and your Node.js 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

chromiumly 6 and 7, each in one folder.

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.

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 chromiumly

npm init -y makes a package.json for the folder, and npm install adds chromiumly, version 6.0.0.

bash
npm init -y
npm install chromiumly@6.0.0

You should see: npm print the new package.json, then an installation summary. Package totals and audit results may vary.

Step 3. Set the address

This puts Marqius Kern's address in .env, which chromiumly reads by itself.

bash
echo 'GOTENBERG_ENDPOINT=http://localhost:3000' > .env

You should see: nothing printed.

Step 4. Make a small price list

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

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

Step 5. Write the program

Save this as convert.js:

javascript 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

bash
node convert.js
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.

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.

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

You should see: 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.

bash
npm init -y
npm install chromiumly@7.0.0

You should see: npm print the new package.json, then an installation summary. Package totals and audit results may vary.

Step 3. Set the address

bash
echo 'GOTENBERG_ENDPOINT=http://localhost:3000' > .env

You should see: nothing printed.

Step 4. Make a small price list

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

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

Step 5. Write the program

The program is the same as for version 6. Save it as convert.js:

javascript 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

bash
node convert.js
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:

  • Version 6: its tests use a stand-in for the server. Use the example above to check the integration in your environment.
  • 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, paperWidth and paperHeight; 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.3 in the server's environment;
  • with basic auth, chromiumly reads GOTENBERG_API_BASIC_AUTH_USERNAME and GOTENBERG_API_BASIC_AUTH_PASSWORD, the same variables the server reads with --api-enable-basic-auth: they serve both sides, as before.

Compatibility results

chromiumly's own tests replace the network with a stand-in, so they do not establish compatibility with a running server. Use the examples above to check chromiumly 6 or 7 against your Marqius Kern deployment, then compare your own documents.

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

Yes, versions 6 and 7: chromiumly 6 is written for Gotenberg 8 and chromiumly 7 for Gotenberg 9, and Marqius Kern answers both APIs on one server.

Do I need to change chromiumly'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.