6
votes

I am using wkhtml2pdf to generate pdf files, the local binaries work just fine, but i don't know why i'm having 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 while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory " stdout: ""

My composer.json includes these 3 files 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 handles wkhtml2pdf binaries.

Snappy is correctly configured to load the binaries from the 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, when i'm trying to generate a pdf, in the moment i call wkhtml2pdf it stops with an error about libjpeg.so.8 that is something i know nothing about.

1
having the exact same issue. Have you managed to solve yet?Gaz_Edge
I just forced composer to download an older version of wkhtml2pdf "h4cc/wkhtmltopdf-amd64": "0.11.0-RC1", I'm guessing libjpg.so.8 is a Cedar14 library and my project is on Cedar10. Just guessing.Mercality
Yet thats the route I went in the end. I think it is more to do with the fact that wkhtmltopdf no longer has some of the static libraries in it. I noticed the author of h4cc repo has raised a ticket github.com/wkhtmltopdf/wkhtmltopdf/issues/1822 and github.com/h4cc/wkhtmltopdf-amd64/issues/5Gaz_Edge
what operating system are you using?rajesh ujade
Can you please post the output of commands 1. php -r 'print_r(gd_info());' and rpm -qa | egrep 'jpg|png' and locate libjpeg.so.rajesh ujade

1 Answers

2
votes

1) Locate the "missing library:

locate libjpeg.so.8

2) try to run strace on the static binary and check the log, where it is looking for the missing lib:

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

After you find out where it is looking for it, you can simply put there for the static binary, and it should start to work ...

I know this is not a "nice" solution, but with specific, hard-to-find libraries / binaries this is the only way to get them working ...