Forum How do I...?

Trying to create my first test pdf failing with PHP

Aninemity
Hi. I've just downloaded and installed Prince and am trying to create my first test PDF.

Here's my code:

require_once dirname(__FILE__).'/prince.php';

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

$prince->setHTML(1);
$prince->setLog("/log.txt");
$prince->setPDFTitle("Test File");

$html = file_get_contents(dirname(__FILE__)."/out/test.html");

header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="foo.pdf"');

$ret = $prince->convert_string_to_passthru($html);



The test.html file has this content:

<!DOCTYPE html>
<html>
<head></head>
<body>
	<h1>hello world!</h1>
</body>
</html>


The PDF is loading (if I use 'inline' instead of attachment), but it's a blank document. When I use 'attachment', the file is 0 bytes in size.

I can't figure out what I'm doing wrong here. Any ideas??
mikeday
Can you successfully run Prince manually from the command-line?

Is /log.txt created? Since / is probably not writable from PHP, perhaps try putting it in /tmp/log.txt?