Forum How do I...?

Troubles using PHP wrapper

Darkfish
Hello,

At first, thanks for this amazing tool !

I used prince in command line under mac osX to generate some PDF from HTML documents. Know, i need to generate some file, using the PHP wrapper, and I have some troubles.

I'm using MAMP as webserver.

So here is my sample to generate a pdf document :

<?php

require "prince.php";

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

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

if(!$prince) die("Prince instantiation failed");

$logLoc = '/Users/antoine/Documents/log.txt';
if(!$prince->setLog($logLoc))die("<p>Error setting error log to $logLoc</p>");

$prince->setHTML(1);

$xmlString="<h1>Hello World</h1><p>This is a test. Did you guess?</p>";
if(!$prince->convert_string_to_passthru($xmlString))die("Error running Prince");

?>


So, first problem is that the setLog method is not working. If i comment the setLog call, then my PDF is download. I open it with an text editor, and inside is displayed my error message "Error running Prince".

I don't know what to do, am I doing something wrong ?

Thx for yours answers !
mikeday
setLog() doesn't return anything, so it doesn't need an if statement. Are any error or warning messages appearing in the MAMP logs?