0

I spent the last three days trying to bring wkhtmltoimage to work on my shared webspace. I do not have root access. Hence, the wkhtmltoimage is in directly in my htdocs directory.

Here's my code:

shell_exec('wget http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.11.0_rc1-static-  i386.tar.bz2');

shell_exec('tar -xvf wkhtmltoimage-0.11.0_rc1-static-i386.tar.bz2');

$output = shell_exec('wkhtmltoimage-i386 google.com google.png');
echo "<pre>$output</pre>";

The first two shell_exec's work fine, but I'm unable to make a screenshot. Any ideas? (Have tried omitting the "i386" as well as putting an "./" before the wkthmltoimage, no success).

This post: How to install wkhtmltopdf on a linux based (shared hosting) web server didn't help either.

Any help is gladly appreciated.

UPDATE Using an SSH connection I get the following terminal code

$ wkhtmltoimage-i386 google.com google.png
wkhtmltoimage-i386: not found
$ ./wkhtmltoimage-i386 google.com google.png
$ Segmentation Fault
Community
  • 1
  • 1
Matt
  • 15
  • 1
  • 5
  • Are you getting any errors? What is the response when you run this command? Can you even run it over ssh? – Mitch Dempsey Nov 12 '12 at 19:05
  • No, I don't get any error codes, only a blank page. Haven't tried it over SSH yet. – Matt Nov 12 '12 at 19:10
  • Try it over SSH. That will probably be much more useful. You can see what errors are happening if any. – Mitch Dempsey Nov 12 '12 at 19:10
  • the directory its in may need to be set to +x and, from the shell is the best way to start. –  Nov 12 '12 at 19:13
  • Ok via SSH I get the error code: Segmentation Fault. I should have writing permission though. Any ideas? – Matt Nov 12 '12 at 20:47
  • I was able to solve the issue by switching to a managed server instead of shared webspace. However I could not have seen the differences in performance between the server and the webspace without using the SSH. Thanks for that advice. If someone has an idea on how to solve the segmentation fault issue on webspace, I'm glad to hear it. – Matt Nov 12 '12 at 22:11
  • This has a ton of different possibilities, here are a few steps that might help; Does `wkhtmltoimage-i386 --version` produce a segfault? What if you rename it to simply wkhtmltoimage, it sometimes worked for some insane reason. Does converting something extremely simple `

    test

    ` work? Does `xvfb-run --server-args="-screen 0, 1280x1024x24" wkhtmltoimage-i386 --use-xserver http://www.google.com google.pdf` work? After those, go through http://code.google.com/p/wkhtmltopdf/issues/list?q=segfault all of those. Sorry for not giving a real answer :)
    – Joel Peltonen Nov 13 '12 at 09:41

3 Answers3

2

If you have errors with wkhtmltoimage, (Segmentation Fault when run the binarie wkhtmltoimage-amd64) this steps worked for me:

Environment: CentOS 5.9, 64 bits, on Xen virtualized cloud environment, only terminal/SSH setup (without any x-windows engine).

Install dependences/packages (order is not relevant):

  • openssl-devel
  • urw-fonts
  • libXext
  • libXrender
  • libfontconfig.so.1

Download 32 bits last stable version (wkhtmltoimage-i386) and run (yes, your system is 64 bits).

Simple Test:

wkhtmltoimage http://test.com/testpage.php /home/user/testimage.jpg

Notes:

When run the app still a Warning message of graphic mode. Ignore it or install a x-window engine (perhaps you will never use or setup it).

Make sure to put the binary file in a directory with the apropiate permissions.

Make sure to run the binary file in relative or absolute form for all the parameters (for example /usr/local/bin/wkhtmltoimage /home/user/test.html /home/user/test.jpg)

Alejandro Quiroz
  • 2,604
  • 1
  • 15
  • 17
0
  1. try to use wkhtmltoimage 0.12.0 from wkhtmltopdf.org
  2. check if using --disable-javascript works for the sample page.
  3. see if this solution on the mailing list works for you.
ashkulz
  • 792
  • 3
  • 6
-1

Based on my recent research on this topic, there seems to be an issue in wkhtmltoimage 0.11 version. This will help you setup wkhtmltoimage for linux. You have to use Xvfb a display server.

EDIT: other help article

  1. Set up wkhtmltoimage
  2. Using Xvfb

Regards,
HBKsagar

Hbksagar
  • 548
  • 7
  • 17