wkhtmltopdf migration

wkhtmltopdf for .NET: DinkToPdf code, no libwkhtmltox to install

Update, 24 November 2026. Both packages are available on NuGet: Marqius.DinkToPdf and Marqius.Wkhtmltopdf, version 0.12.15.

Marqius

Two illustrated invoice proofs aligned with a brass rule on a green desk

The problem this page solves

Your .NET program uses DinkToPdf or its maintained fork. Your code looks like this, and it is fine:

csharp
var converter = new SynchronizedConverter(new PdfTools());
var doc = new HtmlToPdfDocument()
{
    GlobalSettings = { ColorMode = ColorMode.Color,
                       Orientation = Orientation.Portrait,
                       PaperSize = PaperKind.A4 },
    Objects = {
        new ObjectSettings() {
            PagesCount = true,
            HtmlContent = "<h1>Invoice 1042</h1><p>Total: 1,630.00 EUR</p>"
        }
    }
};
converter.Convert(doc);

But under that code sits a native file, libwkhtmltox, that you must install yourself — the right one for the base image and the CPU. On new systems that file is the whole problem:

  • Unable to load shared library '/app/libwkhtmltox.so' — the file is not in the image (see the Docker fix)
  • System.BadImageFormatException … 0x8007000B — the file is there but built for another CPU

The change

One reference, and nothing else changes:

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

Your SynchronizedConverter, HtmlToPdfDocument, GlobalSettings, ObjectSettings, headers, footers, load options — all keep their names and shapes. What changes is underneath: there is no libwkhtmltox to load. The program that does the work is inside the package, one statically linked file per platform, selected automatically.

By construction:

  • There is no .so to fail to load, so the DllNotFoundException above cannot happen.
  • The platform package matches your runtime identifier, so the BadImageFormatException cannot happen.
  • Alpine, Debian, Ubuntu 26.04, ARM64 — the same reference, no per-base Dockerfile steps.

Tested on

  • On every package build, by the project's own CI: 34 unit tests on Windows Server 2025 and 2022, Linux x64 and ARM, macOS, and Docker; plus a 27-document comparison with the original DinkToPdf, page by page, on Linux and Windows.
  • By hand on publish day, from the live registry: a clean .NET 8 container, dotnet add package Marqius.DinkToPdf, the manual's first example exactly as printed — invoice.pdf is ready, 7,842 bytes, one page, the text correct.
  • In a container without fonts, the package answers with its own instructions (install fonts-liberation2 fonts-dejavu-core, or copy the fonts from the marqius/wkhtmltopdf image) instead of a broken PDF.
  • The benchmark, reproducible from tests/bench in the repository: 7 ms per PDF where the libwkhtmltox path takes 212 ms; 265 PDFs a second against 4.7; 23 MB of server space against 45.

Before you switch

Save a PDF your program makes today. Make the same PDF through the package. Compare:

bash
marqius-wkhtmltopdf compare old.pdf new.pdf

It gives a verdict and lists each difference with its page and its kind: text, number, date, page break, font, spacing.

Sources

Reader questions

Is my DinkToPdf code compatible?

The classes and settings keep their names and shapes — all of DinkToPdf 1.0.8's API, compared line by line with the original on every build (375 of 375 lines). Even the raw WkHtmlToXBindings calls work, and apps already compiled against DinkToPdf load this package unchanged. See the developer manual in Sources.

Does it work in Docker and Alpine?

Yes — that is the point. No RUN step installs a native file; the platform package rides with the publish output.

What about the maintained fork?

Its users face the same native-file step. The same change applies.

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, of DinkToPdf and of its fork.