Forum How do I...?

PHP basic code

simon.goodchld
Hi - I am evaluating Prince XML for a client who wants to generate PDF from HTML (generated on the fly). I am testing on Mac OSX and PHP5.

Installed ok, and works via command line (and very impressed with results at first glance!).

However, now trying to get PHP code working, and I am not getting any output to the log file (/tmp/prince.log presumably) and no errors are returned. The code is:

require_once('prince.php');

$prince = new Prince('/usr/local/bin/prince');

$path = '/Users/simongoodchild/sites/wordpress_quote/';
$msgs = array(); 

print_r($prince);

echo "<br><br>";

if (!$prince->convert_file_to_file($path.'readme.html', $path.'readme.pdf', $msgs))
{
	echo "Failed<br>";
   	print_r($msgs);
} else {
	echo "Success<br>";
}

echo "<br><br>Done ".time();


which returns:

Prince Object ( [exePath:private] => /usr/local/bin/prince [styleSheets:private] => [isHTML:private] => [baseURL:private] => [doXInclude:private] => 1 [httpUser:private] => [httpPassword:private] => [logFile:private] => [embedFonts:private] => 1 [compress:private] => 1 [encrypt:private] => [encryptInfo:private] => ) 

Failed
err = 
wrn = 
inf = 
Array ( ) 

Done 1288603357


No PDF is generated, and the log file remains as previous (from testing installation with /usr/local/bin/prince --version > /tmp/prince.log 2>&1), ie:

Prince 7.1
Copyright 2002-2010 YesLogic Pty. Ltd.
Non-commercial License


Any ideas? Without any log file output I'm at a bit of a loss and have tried several examples from the forums, with the same result.

I also tried changing the log file to another file, but no log was output, in case it's not /tmp/prince.log!

I've also been through your forums, and although the problem is the same (prince not running?) I've tried everything on http://www.princexml.com/bb/viewtopic.php?f=4&t=2684 with no success (that problem was solved on a Windows platform and spaces in the path).

Many thanks! Simon.

PS. time() is there just so I can be sure the page is changing :)

Edited by simon.goodchld

simon.goodchld
Oh, I also tried adding:

$prince->setLog('/Users/simongoodchild/sites/wordpress_quote/prince.log');


That directory is 777 so shouldn't be permissions? Still not being created...

Output for permissions:

drwxrwxrwx  38 simongoodchild  staff      1292  1 Nov 11:24 wordpress_quote
simon.goodchld
Found the solution with a combination of Google and your forums.

Running with MAMP on OSX the following was the problem: http://www.princexml.com/bb/viewtopic.php?f=4&t=3204

I wonder what impact commenting the two lines will have on MAMP though?