enupal / snapshot

PDF or Image generation from a URL or HTML page easily for Craft CMS
https://enupal.com/craft-plugins/enupal-snapshot/
Other
11 stars 3 forks source link

Error adding wkhtmltopdf paths #4

Closed davist11 closed 6 years ago

davist11 commented 6 years ago

I'm getting an error adding my paths to the plugin settings:

~/www/public_html$ which wkhtmltopdf
/usr/bin/wkhtmltopdf
~/www/public_html$ which wkhtmltoimage
/usr/bin/wkhtmltoimage

screen shot 2018-06-28 at 11 36 41 am

Is there something I'm missing?

andrelopez commented 6 years ago

Hi @davist11

It seems to be correct for me. Could you please try to recreate this issue and post back the Log error message in the storage/logs/web.log file? you can try to search for: [enupal\snapshot\Snapshot::error]

Best,

davist11 commented 6 years ago
2018-06-28 20:15:45 [73.131.188.225][1][-][error][enupal\snapshot\Snapshot::error] Something went wrong when creating the PDF file: The exit status code '134' says something went wrong:
stderr: "QXcbConnection: Could not connect to display 
Aborted (core dumped)
"
stdout: ""
command: "/usr/bin/wkhtmltopdf" --lowquality --dpi '96' --load-error-handling 'ignore' --zoom '1.33' '/storage/av05091/www/public_html/releases/20180628181239/storage/runtime/temp/enupalsnapshottemp/knp_snappy5b357a30f08d22.95505051.html' '/storage/av05091/www/public_html/releases/20180628181239/public/enupalsnapshot/Hamilton_eYuoKb1DdM.pdf'.
2018-06-28 20:15:45 [73.131.188.225][1][-][error][enupal\snapshot\Snapshot::error] Something went wrong when creating the Image file: The exit status code '134' says something went wrong:
stderr: "QXcbConnection: Could not connect to display 
Aborted (core dumped)
"
stdout: ""
command: "/usr/bin/wkhtmltoimage" --format 'jpg' --zoom '1.33' '/storage/av05091/www/public_html/releases/20180628181239/storage/runtime/temp/enupalsnapshottemp/knp_snappy5b357a318c0190.52855801.html' '/storage/av05091/www/public_html/releases/20180628181239/public/enupalsnapshot/Hamilton_RdN4AU6CC6.png'.
2018-06-28 20:15:44 [73.131.188.225][1][-][info][application] $_GET = [
    'p' => 'admin/settings/plugins/enupal-snapshot'
]
andrelopez commented 6 years ago

Hi @davist11

Are you using Debian?

If so I have to do some research about this bug: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2037#issuecomment-62019521

davist11 commented 6 years ago

Looks like Ubuntu 16.04.4 LTS

andrelopez commented 6 years ago

Hi @davist11

Thanks for following up. It looks like the installation steps in our docs does not work for ubuntu 16.04. Could you please confirm that you followed our steps here: https://enupal.com/craft-plugins/enupal-snapshot/docs/getting-started/installation-setup ?

If so, could you please uninstall wkhtmltopdf and try again with these steps:

$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
$ tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
$ cd wkhtmltox/bin/
$ sudo mv wkhtmltopdf /usr/bin/wkhtmltopdf
$ sudo mv wkhtmltoimage /usr/bin/wkhtmltoimage
$ sudo chmod a+x /usr/bin/wkhtmltopdf
$ sudo chmod a+x /usr/bin/wkhtmltoimage
$ sudo apt-get install libxrender1

If you can confirm us that this works. I'll update our docs for ubuntu 16.04

Best, -Andre L

davist11 commented 6 years ago

This is the response I got back from Arcustech

We install xvfb and the xvfb-run command by default when a client asks for wkhtmltopdf to be installed. Wkhtmltopdf needs a X server, and if you're running your application on a VPS, you probably don't have one installed. The solution is install a "virtual" X server. So you'll need to use a command like: xvfb-run wkhtmltopdf http://google.com google.pdf This explains why here: http://elementalselenium.com/tips/38-headless.

andrelopez commented 6 years ago

Hi @davist11

Thank you for following up. I was able to recreate this issue. I was also able to find a simple fix to this issue:

Enupal Snapshot doesn't need that you have installed wkhtmltopdf in the server, it just needs the full path of the wkhtmltopdf and wkhtmltoimage bin files. We can download it via the command line and get the full path from there. We have updated our docs to download wkhtmltopdf from the command line. I have tested these commands in an Ubuntu 16.04 server.

cd ~

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

tar vxf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 

cd wkhtmltox/bin/

pwd

For our example is:

wkhtmltopdf: /home/enupal/wkhtmltox/bin/wkhtmltopdf
wkhtmltoimage: /home/enupal/wkhtmltox/bin/wkhtmltoimage

More info here:

Add wkhtmltopdf to Enupal Snapshot on Ubuntu via command line

Please let me know how it goes

davist11 commented 6 years ago

Ok, it looks like that worked out, thanks.

sanscheese commented 6 years ago

Does this mean it doesn't work with wkhtmltopdf installed from apt-get?

apt-get install wkhtmltopdf

andrelopez commented 6 years ago

Hi @sanscheese

I think the wkhtmltopdf version is too old when you install it via apt-get. What version did you get?

Enupal Snapshot requires just the bin files path. Once you have installed or download you may need to figure out the path of the bin files. For that reason, we have written a guide to just download the bin files and add the path to Enupal Snapshot.

darylknight commented 4 years ago

I just had this problem on DigitalOcean, Ubuntu 18.04. apt-get correctly installs version 12.4, but it's not recognised by Enupal Snapshot, even if I setup symlinks. The problem is that there's no X server (whatever that is?): qt.qpa.screen: QXcbConnection: Could not connect to display

Related to the issue I just filed, the docs don't seem to exist anymore #36, and the link above to "written a guide" is also broken.

Following the commands in https://github.com/enupal/snapshot/issues/4#issuecomment-403223479 solve the problem.

andrelopez commented 4 years ago

Hi @darylknight this is a known bug when installing wkhtmltopdf via apt-get could you please uninstall that and try again with the following instructions? https://docs.enupal.com/enupal-snapshot/getting-started/installation-setup.html#install-wkhtmltopdf-on-ubuntu-via-command-line

You only need to download the lib (installation is not needed) in a safe place on your server.

Please let me know how it goes

darylknight commented 4 years ago

Thanks Andre! I was just commenting on the post above. But yes, following the commands in the comment above (now in the docs) solves the problem on Ubuntu. Cheers!