Search code examples
phpweb-hostingubuntu-18.04wkhtmltopdflaravel-5.8

Laravel: Trying to generate pdf -> sh: 1: wkhtmltopdf: not found - Can I register wkhtmltopdf for the shell?


So I'm in the process of getting into a project that already exists, including hosting it. I've got all the source code (have yet to transfer the files from the old hosting)

The webpage is hosted on a Plesk Onyx 17.8.11, OS Ubuntu 18.04.3 LTS‬. Most of the website runs like a charm, sans anything that includes loading files and the generating of pdfs (maybe other stuff I haven't found yet). When I want to generate a pdf (using a queue worker), I get the error sh: 1: wkhtmltopdf: not found in my laravel.log, which points to the line of code that catches any errors thrown in the pdf-generation.

wkhtmltopdf is installed via composer (and also in the composer.json), both in the project and globally. I already searched the web, and found the hint to use the binary option. However, since the codebase is not exactly small, and I know it runs fine on another host, I don't want to change all instances of generatePdf() to include the option. Because it runs on another server, it feels like there's some configuration I'm getting wrong.

Thanks in advance!

Update: I had to install wkhtmltopdf with patched qt, as described here, now it works like a charm.


Solution

  • Using the hint from @cOle2, I got wkhtmltopdf via apt-get instead of composer. This made wkhtmltopdf usable from anywhere and lead me to another error: The switch --footer-html, is not support using unpatched qt, and will be ignored.qt.qpa.screen: QXcbConnection: Could not connect to display\nCould not connect to any X display. This error lead me here, and reinstalling wkhtmltopdf as described there fixed the problem.

    tl;dr Install wkhtmltopdf as binary WITH patched qt.