You might happen to use the wicked_pdf gem for PDF output in your Rails app. You might happen to use the wkhtmltopdf-binary gem to provide the required binaries. You might want to get the above to work on the latest (at this point 3.0.3-bullseye) Ruby docker image. Short answer: give up. A bit longer answer: it’s easier than you think.
I went down that rabbit hole. I saw that wkhtmltopdf-binary doesn’t provide binaries for Debian 11 (Bullseye). The gem is a huge bloat anyway with all the various binaries included regardless of what platform you use it on.
So I figured, I might as well get wkhtmltopdf directly. Except wkhtmltopdf’s download page doesn’t have Debian 11. There is a pull request even trying to get it to build on Bullseye (at this point in time, unsuccessfully). I tried to compile wkhtmltopdf myself, but this wasn’t something I could pull off exhausted on a long day’s night.
Thus I gave up. As a last hope, I just tried apt-get install wkhtmltopdf
. And it worked. There is an “official” build for Debian 11. Be sure to get rid of the wkhtmltopdf-binary gem completely. You can check if which wkhtmltopdf
points to bundle/bin or not. It shouldn’t. If it does, just delete that binary, you don’t need it.
All tests green.
Except there’s a catch. There always is. Let’s have some history. The “wk” in wkhtmltopdf stands for WebKit. It uses Qt 4’s WebKit that was released with Qt 4.4 sometime before 2009. (A very up-to-date browser indeed!) Except this doesn’t support a few features that you’d want in PDFs, such as footers per page and other delicacies. So wkhtmltopdf uses a patched version of Qt for these features.
Which features stop working if you use the wkhtmltopdf installed from apt. So if you use stuff like footer HTML or --disable-smart-shrinking
, you’re screwed. Either migrate to using puppeteer, or use a version of wkhtmltopdf with patched Qt (on a supported OS). Preferably the former.