wkhtmltopdf migration

wkhtmltopdf: libssl.so.1.1: cannot open shared object file

Heroku-22 and Heroku-24, Ubuntu 22.04 and later, Debian 12 and later, and Alpine 3.19 and later do not have OpenSSL 1.1, and the old wkhtmltopdf builds need it. Here is the cause, and a fix for Rails that keeps wicked_pdf, PDFKit and your templates.

Marqius

You moved your app to Heroku-24, or your server to a newer system. The first PDF fails, and the log ends like this:

text
RuntimeError (Failed to execute:
["/app/vendor/bundle/ruby/3.2.0/gems/wkhtmltopdf-heroku-2.12.6.0/bin/wkhtmltopdf-linux-amd64", …
Error: PDF could not be generated!
Command Error: /app/vendor/bundle/ruby/3.2.0/gems/wkhtmltopdf-heroku-2.12.6.0/bin/wkhtmltopdf-linux-amd64: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

The first two lines come from wicked_pdf. The last line is the error itself.

Why it happens

  • That wkhtmltopdf was built for an older system. When it starts, it asks for OpenSSL 1.1, which is the file libssl.so.1.1.
  • Ubuntu 22.04 and later, Debian 12 and later, and Alpine 3.19 and later come with OpenSSL 3 instead. Heroku-22 is Ubuntu 22.04, and Heroku-24 is Ubuntu 24.04. The file is not there.
  • Installing OpenSSL 1.1 by hand keeps the old program running for a while. On Heroku-24, that means fetching a package made for Ubuntu 20.04 into the Aptfile. People posted that way in the gem's issue #179.

Every Heroku stack still supported has OpenSSL 3. Heroku-20, the last one with OpenSSL 1.1, ended in April 2025. Heroku-22 is next to go. These are Heroku's own dates:

Date

What happens on Heroku-22

20 May 2026

The stack is deprecated

1 June 2026

Warning emails begin for apps that still build

1 November 2026

The first build of each app in a 30-day period fails with a deprecation error

1 February 2027

The same, in every 7-day period

1 April 2027

The same, in every 24-hour period

30 April 2027

The stack reaches end of life

1 May 2027

No further builds are allowed

Source: Heroku, “Heroku-22 end-of-life FAQ”.

Fix it in Rails with one Gemfile line

In your Gemfile, replace gem "wkhtmltopdf-binary" with this line, then run bundle install:

ruby
gem "marqius-wkhtmltopdf"

Take wkhtmltopdf-heroku out too, if it is there. Both gems carry the old program, and wicked_pdf would find it first.

Bundler picks the gem for your platform, and that gem carries the program. Nothing else is downloaded, at install or when your app runs. On Linux and macOS, wicked_pdf and PDFKit find the program by themselves. You need no buildpack and no Aptfile.

Tested in the heroku/heroku:24 image with Ruby 3.2, on 23 November 2026:

Result

gem install marqius-wkhtmltopdf

2 seconds

A two-page invoice with an Arabic line and a Page [page] of [topage] footer

done in 24 to 49 milliseconds, 2 pages

The program inside the gem

one file of 18,405,392 bytes, statically linked, so it loads no system library

Size of the gem file

about 9 MB for each platform. The wkhtmltopdf-binary 0.12.6.10 gem file is 451,814,912 bytes

The test ran on the ARM64 image. We repeated it in the heroku/heroku:26 image, with Ruby 3.3: the gem installed in 3 seconds, and the same invoice printed in 28 milliseconds.

If your code names the program

wicked_pdf and PDFKit find the program by themselves. If an initializer names it, point it at the new one. These are the lines from the gem's guide.

wicked_pdf, in config/initializers/wicked_pdf.rb:

ruby
WickedPdf.configure do |config|
  config.exe_path = MarqiusWkhtmltopdf.executable_path
end

PDFKit:

ruby
PDFKit.configure do |config|
  config.wkhtmltopdf = MarqiusWkhtmltopdf.executable_path
end

If you want to keep the old wkhtmltopdf

Two ways were posted in the gem's issue #179, and both have a cost.

  • Change the gem and drop the buildpack. Use gem "wkhtmltopdf-heroku", "3.0.0" and remove the buildpack.
  • Add OpenSSL 1.1 to the Aptfile. Fetch the package made for Ubuntu 20.04.

A second error can follow. After one user moved to a newer wkhtmltopdf-binary, the build ended with:

text
!     Compiled slug size: 691M is too large (max is 600M).
!     See: http://devcenter.heroku.com/articles/slug-size

The slug had grown by 155 MB (the gem's issue #185). Each marqius-wkhtmltopdf gem is about 9 MB.

Check the result on your own documents

Save a PDF your app makes today. Make the same PDF with Marqius, then compare them:

bash
marqius-wkhtmltopdf compare old.pdf new.pdf

It lists every difference and names each by its kind: text, number, date, page break, font, spacing. To run the same comparison in every pull request, use the wkhtmltopdf parity check action.

Questions

Do I still need the buildpack or the Aptfile?

No. Remove them. The program is inside the gem and is statically linked.

Is libssl.so.1.1 the same problem as libcrypto.so.1.1?

Yes. They come as a pair from OpenSSL 1.1. Whichever of the two your system reports first, the cause and the fix are the same.

Will my PDFs look the same?

Compare them, on the documents you print. The wkhtmltopdf parity suite publishes how closely the two programs match, document by document, for every release. The decisive check is on your own templates.

What about Python, PHP, Node or .NET on Heroku?

The program is the same. We have tested the install on Heroku-24 and Heroku-26 for Ruby only. Write to hello@marqius.com and we will work through your stack with you.

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. Plans and licences

Who makes it?

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

Sources