Forum How do I...?

Not working with PHP

vividearth
Hi

I am trying to evaluate Prince for a client. The pdf creation is very good and just what they need but I am having trouble getting it working with PHP on both windows and linux (ubuntu server and desktop).

I am calling the convert like this:

$prince = new Prince('/usr/local/prince');
//print_r($prince);
$prince->setLog(dirname(__FILE__).DS.'prince.log');
if (!$prince->convert_file_to_file(dirname(__FILE__).DS.'index.html', dirname(__FILE__).DS.'test.pdf', &$errors))
{
print_r($errors);
}

but all I get back is an empty array. There is nothing in Prince or Apache logs so I am a bit stumped as to how to dedug issue - any suggestions?

Thanks
Dave
vividearth
Ignore - working fine on linux now I have the path correct... :oops: Can live without windows.
vividearth
Hmmm still not there - although it works with local files if I try to convert over http I get no results, no errors and nothing in the log. bAny idea what might be going wrong?

Also are there any good examples of using prince through the API - don't mind which language?
mikeday
So even from the command-line you can't convert a HTTP URL? Or only from PHP? Is the Prince log file created at all? If not, can you check if the PHP script has write permissions for that directory?
vividearth
Some further info.

I tried running this example from the command line:

prince --no-author-style -s http://www.princexml.com/howcome/2008/wikipedia/wiki2.css \
http://en.wikipedia.org/wiki/Finland -o finland.pdf

and got this error back:

prince: relocation error: /lib/libnss_files.so.2: symbol __rawmemchr, version GLIBC_2.2.5 not defined in file libc.so.6 with link time reference

I am running ubuntu 10.04.
mikeday
Okay, that's a very low-level error caused by libraries that have changed since Ubuntu 9.04. Can you try downloading this dynamically linked package instead? It should use whichever libraries are installed on your system, and hopefully fix the problem.
vividearth
Hi Mike

Thanks for the reply. I now get the following error:

/usr/local/lib/prince/bin/prince: error while loading shared libraries: libgif.so.4: cannot open shared object file: No such file or directory.

I have checked and libgif4 is installed.

Any ideas?

Dave
mikeday
So /usr/lib/libgif.so.4 does exist with that name? Or is it located in some other directory?
vividearth
I have libgif.so.4.1.6 with 3 links of libgif.so, libgif.so.4 and libgif.so.4.1 all in /usr/lib.
mikeday
That really should work, then! Is this a 32-bit Ubuntu system or 64-bit? Does running "ldd /usr/lib/prince/bin/prince" show up anything interesting?
vividearth
It is 64 bit and strangely I get this:

ldd: /usr/lib/prince/bin/prince: No such file or directory
mikeday
If it is a 64-bit system, try downloading the 64-bit dynamically linked package here. (The reason ldd returned no output is that I got the path wrong; you installed Prince in /usr/local, not /usr, so it should have been /usr/local/lib/prince/bin/prince).