Libjpeg.so.8 not found when using wkhtmltopdf static binary

I use wkhtml2pdf to create PDF files, local binaries work fine, but I don’t know why I have this problem when deploying to heroku. I get this error

The exit status code "127" says something went wrong: stderr: "/ app / vendor / h4cc / wkhtmltopdf-amd64 / bin / wkhtmltopdf-amd64: error loading shared libraries: libjpeg.so.8: failed open shared object file: There is no such file or directory "stdout:" "

My composer.json includes these 3 files that I need

"h4cc/wkhtmltopdf-amd64": "0.12.x", "h4cc/wkhtmltoimage-amd64": "0.12.x", "barryvdh/laravel-snappy": "0.1.x" 

Where snappy is the class that processes wkhtml2pdf binaries.

Snappy configured correctly to download binary files from vendors folder

  'pdf' => array( 'enabled' => true, 'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'), 'options' => array(), ), 'image' => array( 'enabled' => true, 'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'), 'options' => array(), ), 

But the problem is that when I try to create a pdf file, at the moment when I call wkhtml2pdf, it stops with an error about libjpeg.so.8, about which I know nothing.

+5
source share
1 answer

1) Find the "missing library":

 locate libjpeg.so.8 

2) try running strace on a static binary and check the log where it looks for the missing lib library:

 strace /app/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 

After you find out where he is looking for him, you can just put a static binary there, and it should start working ...

I know that this is not a β€œpleasant” solution, but with specific, hard-to-reach libraries / binaries, this is the only way to make them work ...

+2
source

Source: https://habr.com/ru/post/1201050/


All Articles