---
type: Article
title: Unable to load shared library libwkhtmltox.so — the fix | Marqius
description: DinkToPdf does not carry the file it needs. See why the error
  appears in Docker and on new systems, and the two ways to fix it.
resource: https://marqius.com/blog/dinktopdf-unable-to-load-libwkhtmltox/
tags:
  - marqius
  - journal
status: stable
sources:
  - id: official-page
    resource: https://marqius.com/blog/dinktopdf-unable-to-load-libwkhtmltox/
    last_modified: 2026-11-24T13:09:28.406Z
generated:
  by: process:marqius-site-build
  at: 2026-11-24T13:12:45.547Z
x_marqius:
  language: en
  source_sha256: 7a4532073481603aa052065147c7b7b42f7ef2cc9479225b4919134e1f84dbe1
  extraction: public-main-content
---

wkhtmltopdf migration

# DinkToPdf: Unable to load shared library 'libwkhtmltox.so' — the cause and the fix

Your .NET program prints invoices or reports with DinkToPdf. It worked on your machine. In the container, it dies on the first PDF:

Marqius November 19, 2026

text

```
Unhandled exception. System.DllNotFoundException:
Unable to load shared library '/app/libwkhtmltox.so' or one of its dependencies.
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable
```

## What the message means, in plain words

DinkToPdf does not make PDFs itself. It loads a second file, `libwkhtmltox.so`, and that file does the work. That file is not part of DinkToPdf, and it is not part of .NET. It must be on the machine before the first PDF.

The runtime could not load the file. It may be missing, outside the library search path, or missing a system library it needs. If the file is present, run `ldd /app/libwkhtmltox.so` inside your Linux image and look for a dependency marked **not found**.

## Why it appears in Docker and on new systems

-   The file only exists for the systems its makers built it for. The archived project published separate packages for specific distributions and CPUs, including Debian 12 and Ubuntu 22.04.
-   Alpine images need a different build (`musl`) than Debian images.
-   ARM machines — Apple Silicon, AWS Graviton, the ARM CI runners — need their own build. The error is common on ARM EC2 instances for exactly this reason.
-   Multi-stage Docker builds often copy the app but not the native file.

## The fix: put the file into the image

On a Debian-based image, install the wkhtmltox package that matches your base. For `mcr.microsoft.com/dotnet/aspnet:8.0` (Debian 12, bookworm):

dockerfile

```
RUN apt-get update && \
    apt-get install -y --no-install-recommends wget ca-certificates && \
    wget -q https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb && \
    apt-get install -y --no-install-recommends ./wkhtmltox_0.12.6.1-3.bookworm_amd64.deb && \
    rm wkhtmltox_0.12.6.1-3.bookworm_amd64.deb
```

Three rules that decide whether this works:

1.  **Match the base.** Bookworm base → bookworm file. Bullseye → bullseye. Ubuntu 22.04 → jammy.
2.  **Match the CPU.** `_amd64` on x64, `_arm64` on ARM.
3.  **Alpine is different.** It needs a musl build; the Debian `.deb` will not load there.

## The related error: `System.BadImageFormatException`

If you see `0x8007000B` instead, the file was found but does not match the CPU: a 64-bit program loading a 32-bit file, or x64 loading an ARM file. The fix is the same idea — install the build that matches — and one more check: publish your app for the right runtime, for example `dotnet publish -r linux-x64`.

## The deeper problem, and the way out

The file you are installing is from a project that was archived in January 2023. The upstream release includes separate Debian Bookworm and Ubuntu Jammy packages. Every fix above is a way to keep using it.

Update, 24 November 2026. We make Marqius.DinkToPdf: DinkToPdf's own API — every class, method and setting, compared line by line with the original on every build — with no `libwkhtmltox` at all. One reference and the errors above cannot happen:

xml

```
<PackageReference Include="Marqius.DinkToPdf" Version="0.12.15" />
```

The full guide, from your first PDF to Docker: [wkhtmltopdf for .NET](https://marqius.com/blog/wkhtmltopdf-dotnet/)

## Sources

-   [The error on an ARM EC2 instance](https://github.com/rdvojmoc/DinkToPdf/issues/183)
-   [DinkToPdf, unchanged since 2017](https://www.nuget.org/packages/DinkToPdf)
-   [The last official Linux builds](https://github.com/wkhtmltopdf/packaging/releases/tag/0.12.6.1-3)
-   [The guide for installs that fail outright](https://marqius.com/blog/wkhtmltopdf-no-installation-candidate/)
-   [Plans and licences](https://marqius.com/wkhtmltopdf-buy/)

## Reader questions

### Is DllNotFoundException the same as BadImageFormatException?

No. "Unable to load shared library" means the runtime could not load the file or one of its dependencies. "Bad image" (0x8007000B) means the file is there but built for a different CPU. Both are fixed by installing the right build.

### Why did it work on my Windows machine?

Windows DinkToPdf setups usually carry wkhtmltox.dll next to the app already. The container starts empty, so the Linux file is simply absent.

### What does it cost?

There are two licences. The Community licence is free: for personal projects, for teaching and learning, and for open-source projects, including their CI test runs and documentation builds. The commercial licence is for businesses.

### Who makes it?

Marqius is commercial software from Simple AI LLC. It is independent of the wkhtmltopdf project and of DinkToPdf.

## Keep reading

[Make PDFs in .NET: the Marqius.DinkToPdf manual](https://marqius.com/blog/html-to-pdf-dotnet-dinktopdf/) [The .NET PDF benchmark: 7 ms against 212 ms](https://marqius.com/blog/wkhtmltopdf-dotnet-benchmark/) [wkhtmltopdf as a service: POST the HTML, get the PDF](https://marqius.com/blog/wkhtmltopdf-serve/) [All journal guides](https://marqius.com/blog/)

Source for this page [^official-page].

[^official-page]: https://marqius.com/blog/dinktopdf-unable-to-load-libwkhtmltox/

[Browse this section](index.md) · [Knowledge index](../index.md)
