2
votes

I'm having real trouble getting this binary to run (I've spent days and days!).

I want to get wkhtmltoimage running on a Linux OS with Apache web server (icdsoft.com), and the hosting company tells me I should use static-amd64. I downloaded the file at:

http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltoimage-0.11.0_rc1-static-amd64.tar.bz2 and uncompressed it.

I don't have ssh access to the server, but the hosting company said I could run the binary from a directory such as:

/home/notice/www/www/wkhtmltoxdoc/

... although I thought it had to be something like:

/usr/local/bin/

So I've uploaded the file "wkhtmltoimage-amd64" to /home/notice/www/www/wkhtmltoxdoc/ and renamed it "wkhtmltoimage". I also made a copy of this file and called it "wkhtmltoimage.bin" (some people said that helped). I changed both files and the directory "wkhtmltoxdoc" to have permissions 777.

Then I tried calling the binary (with and without the .bin extension) using php which did not produce any results (no file was created):

Note: [bbc_url] = http://www.bbc.com (I couldn't post with more than 2 links)

shell_exec('./wkhtmltoxdoc/wkhtmltoimage.bin [bbc_url] ./wkhtmltoxdoc/bbc.jpg');
shell_exec('./wkhtmltoxdoc/wkhtmltoimage [bbc_url] ./wkhtmltoxdoc/bbc2.jpg');

I then tried to get the binary to run on my local system OSx 10.6.8 - I copied both the previous amd-64 file and the 32-bit file (http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltoimage-0.11.0_rc1-static-i386.tar.bz2) to /usr/local/bin and changed their permissions to 777. These are the results of going to the /usr/local/bin directory and trying to run it in Terminal:

$ wkhtmltoimage-amd64 [bbc_url] /Users/jazz/Desktop/bbc.jpg
-bash: /usr/local/bin/wkhtmltoimage-amd64: cannot execute binary file

$ wkhtmltoimage-i386 [bbc_url] /Users/jazz/Desktop/bbc.jpg
-bash: /usr/local/bin/wkhtmltoimage-i386: cannot execute binary file

The goal is to get wkhtmltoimage on the external server, but I was just trying to test on my local.

I found this in a manual for wkhtmltoimage: "On Linux it depends on both glibc and openssl, furthermore you will need to have an xserver installed but not necessary running. You will need to have different fonts install including xfonts-scalable (Type1), and msttcorefonts."

My server support said: "Glibc and OpenSSL are available on the server. However XServer is not. We tried running the command from the shell. It is running without producing any errors. However, it fails to create the image. It is quite likely that without the XServer it won't work. Unfortunately, there is no way for us to install an XServer. It is the graphics system for Linux which is not suitable for hosting servers."

If anyone can help me with this, I would really really appreciate it! Many thanks!

1

1 Answers

2
votes

I had success, locally on my mac, running the OSX wkhtmltoimage static version (latest pre-packaged i found : wkhtmltoimage-OSX-0.10.0_rc2-static.tar.bz2) and for the server i uploaded the i386 version.

I tested it out locally in my OSX terminal first

./wkhtmltoimage --width 1280 --height 700 http://www.google.com wktest.jpg

(update) Some tips that might be useful:

  • Make sure the execute bit is set on the program (chmod u+x or ugo+x)
  • i installed wkhtml on the linux server under my home directory
    ~/wkhtmldir (/home/username/wkhtmldir).
    it seems the program can find and use (TTF) fonts placed in ~/.fonts

edit:
if you have problems with css font usage on the Linux server (i had),
e.g.: undefined symbol: FcFreeTypeQueryFace, then fontconfig might need updating
see this issue: http://code.google.com/p/wkhtmltopdf/issues/detail?id=352