OT: Installing static binary of wkhtmltopdf

This is OT but have not been able to get a response elsewhere (stack overflow and the project site itself) so thought someone here might know or have some ideas.

First, I am using wkhtmltopdf stand alone without any of the rails gems as I found that for some reason using WickedPdf or PdfKit my pdf’s did not generate with active links from the links from those in the html. When I run wkhtmltopdf from the console, I get good, active links.

I am running production on Ubuntu 10.04 Server. I need whhtmltopdf to work without an X Server (as I have no gui there). The wkhtmltopdf static binary is said to have a patched QT that will allow this. However I have not been able to get the static binary to work. These are the results the steps I took to install:

Result: Once installed (see steps below), when I execute wkhtmltopdf in the terminal, it does not fire up… just returns me to the prompt - like it ran and did something, but with no error but no output:

:/usr/bin$ wkhtmltopdf
:/usr/bin$

Same behavior if I put args:
:/usr/bin$ wkhtmltopdf http://www.google.com test.pdf
:/usr/bin$

Am I doing something wrong — my understanding that the static binary should just fire up. Perhaps missing some dependency? Is there a way to get some verbose output?

These are the steps I have followed:

In /usr/bin:

  1. Confirmed that the existing (non-static) wkhtmltopdf resides there and that it executes. When I execute it with no args I get the help/about output from the app.

  2. Moved the existing wkhtmltopdf out of the directory (renamed it)

  3. Get the static binary: sudo curl -C - -O http: //wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2

  4. Untar: tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2

  5. Rename: mv wkhtmltopdf-i386 wkthtmltopdf

  6. Get (apparently) necessary packages: sudo apt-get install openssl build-essential xorg libssl-dev

I am running production on Ubuntu 10.04 Server. I need whhtmltopdf to
work without an X Server (as I have no gui there). The wkhtmltopdf
static binary is said to have a patched QT that will allow this.
However I have not been able to get the static binary to work. These
are the results the steps I took to install:

Result: Once installed (see steps below), when I execute wkhtmltopdf
in the terminal, it does not fire up... just returns me to the
prompt - like it ran

[...]

In /usr/bin:

1) Confirmed that the existing (non-static) wkhtmltopdf resides there
and that it executes. When I execute it with no args I get the
help/about output from the app.

Don't install anything manually in /usr/bin. That directory belongs to
your system (Ubuntu). Use /usr/local (or /usr/opt in special cases) for
your own stuff.

2) Moved the existing wkhtmltopdf out of the directory (renamed it)

Don't. Just deinstall it.

3) Get the static binary: sudo curl -C - -O http: //
wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz
2

4) Untar: tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2

Sanitiy check: is the unpacked binary executable? What do you get if you
start it with its complete path: /usr/local/bin/wkhtmltopdf-i386?

5) Rename: mv wkhtmltopdf-i386 wkthtmltopdf

Do this in /usr/local/bin and instead of renaming just add a symlink.

6) Get (apparently) necessary packages: sudo apt-get install openssl
build-essential xorg libssl-dev

Do you get this impression from
http://code.google.com/p/wkhtmltopdf/wiki/compilation ? That page
describes how to *compile* the binary for yourself, something you don't
need to do. You probably already have installed openssl, but you won't
need the other packages. They don't hurt either (apart from taking up
space).

Finally, do you get any output from

$ /usr/local/bin/wkhtmltopdf-i386

If you don't get anything, try

$ strace /usr/local/bin/wkhtmltopdf-i386

to get a trace of system calls the program is executing. You may need to
install the strace package for that.

Michael

Michael - thanks, and for the reminder on usr/bin…

Sanitiy check: is the unpacked binary executable? What do you get if you
start it with its complete path: /usr/local/bin/wkhtmltopdf-i386?

That is the rub… when I run this I get no error but no love either, it just gives me a new command prompt. As if I was executing a program that has no functionality:

:/usr/local/bin$ /usr/local/bin/wkhtmltopdf-i386
:/usr/local/bin$

also trying it with standard arguments to create a pdf:
/usr/local/bin/wkhtmltopdf-i386 http://www.google.com google.pdf
:/usr/local/bin$

I would guess if there was a dependency problem I should receive an error.

So would this mean that this file is a dud? That is where I have been stuck thinking that I must be doing something wrong.

Jumped the gun, did not try the strace command. Got:

execve("/usr/local/bin/wkhtmltopdf-i386", ["/usr/local/bin/wkhtmltopdf-i386"], [/* 18 vars */]) = 0
[ Process PID=14199 runs in 32 bit mode. ]
old_mmap(0x13d8000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0x13d8000) = 0x13d8000
readlink("/proc/self/exe", “/usr/local/bin/wkhtmltopdf-i386”, 4096) = 31
old_mmap(0x8048000, 23455403, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x8048000
mprotect(0x8048000, 23455400, PROT_READ|PROT_EXEC) = 0
old_mmap(0x96a7000, 786811, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0x165e000) = 0x96a7000
mprotect(0x96a7000, 786808, PROT_READ|PROT_WRITE) = 0
old_mmap(0x9768000, 87848, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x9768000
brk(0x977e000) = 0xb767000
open("/lib/ld-linux.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
_exit(127) = ?

Could that last line be the problem?
When I check /lib I have /lib/ld-linux-x86-64.so.2
But not /lib/ld-linux.so.2

I am just googling to see if I find anything unless you know offhand how to deal with.

Jumped the gun, did not try the strace command. Got:

How *did* you get this output then?

execve("/usr/local/bin/wkhtmltopdf-i386",
["/usr/local/bin/wkhtmltopdf-i386"], [/* 18 vars */]) = 0
[ Process PID=14199 runs in 32 bit mode. ]
old_mmap(0x13d8000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0x13d8000) = 0x13d8000
readlink("/proc/self/exe", "/usr/local/bin/wkhtmltopdf-i386", 4096) =
31 old_mmap(0x8048000, 23455403, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x8048000
mprotect(0x8048000, 23455400, PROT_READ|PROT_EXEC) = 0
old_mmap(0x96a7000, 786811, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0x165e000) = 0x96a7000
mprotect(0x96a7000, 786808, PROT_READ|PROT_WRITE) = 0
old_mmap(0x9768000, 87848, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x9768000
brk(0x977e000) = 0xb767000
open("/lib/ld-linux.so.2", O_RDONLY) = -1 ENOENT (No such file or
directory)
_exit(127) = ?

Could that last line be the problem?
When I check /lib I have /lib/ld-linux-x86-64.so.2
But not /lib/ld-linux.so.2

Are you sure that the i386-binary is the correct one for your system?
If you're running a 64-bit Linux, the amd64 tarball is the right one for
you. No matter if you have an Intel or AMD CPU! The naming is like that
for "historical" reasons, I reckon, as it was AMD who introduced this
extension of the original i386/IA-32 architecture.

See http://en.wikipedia.org/wiki/X86-64 . And have look at the output of
uname -a.

Michael

Michael - you’re the man! It was the amd binary. I had thought I tried that yesterday but must have made a mistake. And yes, I did use strace to get that output – good thing to know about.

Thanks again!

David