PHP - wkhtmltopdf binary

I am using wkhtml2pdf libary in my Laravel application. In my local environment, this works great. My PDF was created correctly. In my .env file , I have:

WKHTML2PDF_BIN_FILE = wkhtmltopdf-amd64

But on my scaleway I have the following error:

enter image description here

My software supports armhf . So I was unable to install the amd / 64-bit versions. I installed wkhtmltopdf on my server like this:

sudo apt install wkhtmltopd

      

But now it doesn't work online. I think my config is wrong (link to bin file). But how can I find out and set the correct link to my WKHTML2PDF_BIN_FILE?

UPDATE:

When I enter the following command:

sudo find / -name "wkhtmltopdf*"

      

Then I get the following results:

/var/lib/dpkg/info/wkhtmltopdf.md5sums
/var/lib/dpkg/info/wkhtmltopdf.list
/var/www/mydomain.com/html/vendor/nitmedia/wkhtml2pdf/src/Nitmedia/Wkhtml2pdf/lib/wkhtmltopdf-i386
/var/www/mydomain.com/html/vendor/nitmedia/wkhtml2pdf/src/Nitmedia/Wkhtml2pdf/lib/wkhtmltopdf-amd64
/var/www/mydomain.com/html/vendor/nitmedia/wkhtml2pdf/src/Nitmedia/Wkhtml2pdf/lib/wkhtmltopdf-0.12.1-OS-X.i386
/usr/share/doc/wkhtmltopdf
/usr/share/man/man1/wkhtmltopdf.1.gz
/usr/bin/wkhtmltopdf

      

I tried changing WKHTML2PDF_BIN_FILE=wkhtmltopdf-amd64

to WKHTML2PDF_BIN_FILE=/usr/bin/wkhtmltopdf

, but this results in:

enter image description here

How can I fix this?

UPDATE 2:

I added this to my config:

WKHTML2PDF_BIN_PATH=/usr/bin/ 
WKHTML2PDF_BIN_FILE=wkhtmltopdf

      

But then I get the error QXcbConnection: Failed to connect to display . I read in this thread that I have to run it with xvfb-run wkhtmltopdf. But where should I add this to the library?

+3


source to share


3 answers


If you check the library code in this block of code , it looks for the binary filename and the path of the binary, which are two separate things.

So, maybe you need to add two env parameters instead of one:



WKHTML2PDF_BIN_PATH=/usr/bin/
WKHTML2PDF_BIN_FILE=wkhtmltopdf

      

+1


source


Try to follow this thread here https://github.com/NitMedia/wkhtml2pdf/issues/33

Create a config file:

app/config/packages/nitmedia/wkhtml2pdf/local/config.php

      



And add paths inside it:

return [
    'debug' => true,
    'binpath' => '/usr/bin/',
    'binfile' => 'wkhtmltopdf',
    'tmppath' => '/tmp/',
];

      

And don't delay deleting the entry .env

.

0


source


Have you tried this on your teminal server;

export DISPLAY=:0

Effective display zeroing.

0


source







All Articles