HUB
Sign inSign up

marqius/wkhtmltopdf

By marqius

•Updated about 10 hours ago

wkhtmltopdf, rebuilt from scratch: same command and options, one file, tested in public.

Image
Integration & delivery
Developer tools
2

6.2K

marqius/wkhtmltopdf repository overview

⁠Supported tags and respective build steps

  • 0.12.17, latest⁠: ready to run, for most teams: the program, its fonts and the demo files (14.1 MB)
  • slim⁠: the same with one font, the smallest (11.1 MB)
  • alpine⁠: Alpine Linux 3.24, with a shell and apk (17.8 MB)
  • trixie⁠: Debian 13 (43.9 MB)
  • bookworm⁠: Debian 12 (42.3 MB)
  • bullseye⁠: Debian 11, past its support (44.3 MB)

New in 0.12.17: Pictures inside SVG drawings now follow the same local-file rules as every other picture.

Earlier releases stay available to pin: 0.12.16, 0.12.15, 0.12.14, 0.12.13, 0.12.12, 0.12.11, 0.12.10, 0.12.9, 0.12.8, 0.12.7, 0.12.6, 0.12.5, 0.12.4, 0.12.3, 0.12.2, 0.12.1, 0.12.0, 0.11.0.

Every tag runs on linux/amd64 and linux/arm64. Sizes are compressed, for amd64. Each link opens the tag on Docker Hub, which lists its build steps layer by layer.

⁠wkhtmltopdf for Docker: the maintained drop-in replacement

Convert HTML to PDF in Docker with the wkhtmltopdf command you already use. This image runs marqius-wkhtmltopdf, a maintained replacement for wkhtmltopdf: the same command, the same options and the same HTML templates. Your code does not change.

Why it matters. wkhtmltopdf's project was archived in January 2023, and Debian 13 and Ubuntu 26.04 no longer include it, so apt-get install wkhtmltopdf fails in their images. Old wkhtmltopdf images also carry Qt, X libraries and hundreds of megabytes. This one is a single program with its fonts, from a 10 MB download, on Intel/AMD and ARM servers.

  • The same PDFs, proven in public. The parity suite⁠ runs the same documents through wkhtmltopdf and marqius-wkhtmltopdf on every release and publishes every result, misses included.
  • Your library keeps working. The own test suites of 15 wkhtmltopdf libraries⁠ pass with it as they pass with wkhtmltopdf.
  • Examples to copy. Runnable examples for 14 libraries⁠, in Python, PHP, Ruby, Node.js, Go, Java, Elixir and .NET, and a migration guide for each wrapper⁠.
  • Signed images. Every tag carries GitHub's build provenance; check one with gh attestation verify oci://marqius/wkhtmltopdf:latest -R marqiushq/marqius-wkhtmltopdf.

⁠Choose your image

TagDownloadOn diskBest for
latest, 0.12.1713 MB26 MBmost teams: the program and its fonts, ready to run
slim11 MB20 MBthe smallest footprint, with one font (Liberation Sans)
alpine17 MB34 MBbuilding your own image on Alpine 3.24
trixie, bookworm42 MB, 40 MB105 MB, 101 MBbuilding your own image on Debian 13 or 12
bullseye42 MB107 MBimages that must stay on Debian 11 for now

Every tag runs on Intel/AMD (amd64) and ARM (arm64) servers. The sizes are for Intel/AMD, as Docker Hub shows them; the ARM images download within 2 MB of these.

⁠Make your first PDF

Run this in any folder. It converts your invoice.html; in an empty folder, the image's own demo invoice, so you can try it straight away:

docker run --rm -v "$PWD:/data" marqius/wkhtmltopdf invoice.html invoice.pdf

Through a pipe, with no folder to share, and as a picture (wkhtmltoimage):

echo '<h1>Hello from a pipe</h1>' | docker run --rm -i marqius/wkhtmltopdf - - > hello.pdf
docker run --rm -v "$PWD:/data" marqius/wkhtmltopdf wkhtmltoimage page.html page.png

Use the same page options as your app, such as --page-size A4 or --margin-top 20mm. For files owned by your account, add --user "$(id -u):$(id -g)". For a trusted document that uses only bundled assets, add --network none.

⁠Not on Docker? Install it on your server

On a Linux server (Intel/AMD or ARM) or a Mac with Apple silicon, one command installs the same program, as on marqius.com. It downloads the latest release, checks it against its published checksum, and gives it the names wkhtmltopdf and wkhtmltoimage, so your app finds it where it found wkhtmltopdf:

curl -fsSL https://marqius.com/marqius-wkhtmltopdf.sh | bash

If a wkhtmltopdf is installed already, nothing is replaced until you say so. This line takes its place and keeps the old program, so you can always go back:

curl -fsSL https://marqius.com/marqius-wkhtmltopdf.sh | bash -s -- --take-over

What "drop-in" means: your app keeps the exact command it runs today.

wkhtmltopdf --page-size A4 --margin-top 20mm --footer-center "Page [page] of [topage]" invoice.html invoice.pdf

The HTML and the code that calls it can stay as they are. If your app names the program's path, set that path. Check your own documents before you switch production.

To update, run the first line again. To return to the version before, or to take it all away:

curl -fsSL https://marqius.com/marqius-wkhtmltopdf.sh | bash -s -- --rollback
curl -fsSL https://marqius.com/marqius-wkhtmltopdf.sh | bash -s -- --uninstall
⁠Or with your package manager

The same program from signed repositories, kept up to date with the rest of the system. It is installed as marqius-wkhtmltopdf, beside any wkhtmltopdf you have; sudo marqius-wkhtmltopdf install gives it the names wkhtmltopdf and wkhtmltoimage when you are ready.

Homebrew, on Apple silicon Macs and Linux:

brew install marqiushq/tap/marqius-wkhtmltopdf

Debian and Ubuntu:

sudo curl -fsSLo /etc/apt/sources.list.d/marqius.sources https://packages.marqius.com/apt/marqius.sources
sudo apt update && sudo apt install marqius-wkhtmltopdf

Rocky Linux, Red Hat, Fedora and Amazon Linux:

sudo curl -fsSLo /etc/yum.repos.d/marqius.repo https://packages.marqius.com/rpm/marqius.repo
sudo dnf install marqius-wkhtmltopdf

Alpine, as root:

wget -qP /etc/apk/keys https://packages.marqius.com/alpine/marqius.rsa.pub
echo https://packages.marqius.com/alpine >> /etc/apk/repositories
apk add marqius-wkhtmltopdf

More help: installing with apt⁠ and wkhtmltopdf on Debian⁠.

⁠Works with your wrapper library, and with Odoo

pdfkit and django-wkhtmltopdf, Snappy and laravel-snappy, wicked_pdf and PDFKit, Rotativa and Wkhtmltopdf.NetCore, and the Node.js and Go wrappers find it where they found wkhtmltopdf. Integrations that load libwkhtmltox as a library cannot use a program in its place.

Tested with Odoo 19 and 20 reports: invoices, quotations, delivery slips and picking lists, one record or several at once, printed through Odoo's own Print button beside wkhtmltopdf 0.12.6.1 (patched Qt).

⁠An HTML to PDF API for your apps

Start a PDF service in one line; your apps send the HTML and get the PDF back:

docker run -d -p 8080:80 marqius/wkhtmltopdf serve
docker run --rm -v "$PWD:/data" marqius/wkhtmltopdf demo invoice.html
curl -F [email protected] localhost:8080 -o invoice.pdf

The first line starts the service, the second puts a demo invoice in your folder, and the third converts it. Check the request and response against your application before you switch an HTTP integration, and keep the service on a private network.

⁠Fonts and languages

latest and the system tags carry Liberation Sans, Serif and Mono, which have the letter widths of Arial, Times New Roman and Courier New, plus DejaVu Sans. slim carries Liberation Sans.

For customers who read Chinese, Japanese, Korean, Hindi, Thai or any other writing system, add the Noto fonts. Put them in a Docker volume once (nothing is installed on the machine itself, and no password is asked) and start the container with them:

docker run --rm -v noto-fonts:/usr/share/fonts debian:bookworm-slim sh -c 'apt-get update -qq && apt-get install -y -qq fonts-noto-core fonts-noto-cjk'
docker run --rm -v noto-fonts:/usr/local/share/fonts:ro -v "$PWD:/data" marqius/wkhtmltopdf in.html out.pdf

Your brand fonts, from a folder, on any machine:

docker run --rm -v "$PWD/fonts:/usr/local/share/fonts:ro" -v "$PWD:/data" marqius/wkhtmltopdf in.html out.pdf

Or built into your own image:

docker build -t my-wkhtmltopdf - <<'EOF'
FROM marqius/wkhtmltopdf:bookworm
RUN apt-get update && apt-get install -y --no-install-recommends fonts-noto-core fonts-noto-cjk \
 && rm -rf /var/lib/apt/lists/*
EOF
docker run --rm -v "$PWD:/data" my-wkhtmltopdf in.html out.pdf

Each letter is set in an installed font that has it, with no font cache to refresh. When a document has letters no installed font has, the program says so and prints the line that installs the right fonts.

⁠Switch with almost no risk

1. Test your own templates. Run the parity suite on them⁠ on your own computer. It shows every difference, and nothing is uploaded.

2. Compare the PDFs your app makes, before and after:

docker run --rm -v "$PWD:/data" marqius/wkhtmltopdf:0.12.17 compare old.pdf new.pdf

3. Keep a way back. In Docker, keep your old image until you are sure. On a server, --take-over keeps your old wkhtmltopdf, and --uninstall puts it back in one line.

⁠Questions

apt-get install wkhtmltopdf fails in my Dockerfile with "Unable to locate package". Why? Debian 13 and Ubuntu 26.04 no longer include wkhtmltopdf. Use this image, or build FROM marqius/wkhtmltopdf:bookworm (or :trixie, or :alpine) to add what your app needs.

Do I need Xvfb or an X server? No. The errors "cannot connect to X server" and "error while loading shared libraries" do not happen here.

Which tag should I use? latest for most teams, slim for the smallest image, and trixie, bookworm or alpine as the base for an image of your own.

Does it run on ARM servers and Apple silicon? Yes: every tag has an arm64 image.

⁠Price

Try it for 30 days without a card. 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 plan once the trial ends. Your PDFs never stop: without a licence, each page carries one small line, Prepared by Marqius, Purchase Licence. See the plans and prices⁠.

Switching manual: https://marqius.com/download/replace-wkhtmltopdf.pdf⁠ · Docker guide: https://marqius.com/wkhtmltopdf/docker/⁠

Compiled proprietary software from Simple AI LLC; no marqius engine source is included.

⁠Factur-X and ZUGFeRD output

Supply Cross Industry Invoice XML from your invoicing software to embed it in the generated PDF. Validate the resulting PDF and XML against the profile your recipient or delivery platform expects.

docker run --rm -v "$PWD:/data" marqius/wkhtmltopdf:0.12.17 --marqius-einvoice invoice.xml invoice.html invoice.pdf

Français. Ajoutez le fichier XML CII de votre logiciel de facturation au PDF. Vérifiez le résultat selon le profil Factur-X demandé par votre destinataire.

Deutsch. Fügen Sie die CII-XML-Datei aus Ihrer Rechnungssoftware in die PDF ein. Prüfen Sie das Ergebnis gegen das vom Empfänger geforderte ZUGFeRD-Profil.

Tag summary

Content type

Image

Digest

sha256:dc78ad07e…

Size

13.4 MB

Last updated

about 10 hours ago

docker pull marqius/wkhtmltopdf