Forum How do I...?

PHP problems with Prince 11

zephyr103
Hi I am using a Mac and XAMPP. Prince works in the command line but not with PHP. The log file is being created but has no content. I think the path to Prince in the constructor is correct but it doesn't seem to make a difference when I put in an incorrect path. $prince->convert_string_to_passthru is just returning false. In Chrome it says "Failed to load PDF document" and Firefox says "This PDF document might not be displayed correctly".

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1'); 

include 'prince.php';

ob_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c4/PM5544_with_non-PAL_signals.png" />
</body>
</html>
<?php
$out = ob_get_clean();

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

$prince->setHTML(1);

$temp_file = tempnam(sys_get_temp_dir(), 'prince_');
chmod($temp_file, 0777);

error_log('temp file name: '.$temp_file);
    
$prince->setLog($temp_file);

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

$prince->convert_string_to_passthru($out);
mikeday
Could you check that you have Prince 11.3 installed and try changing the executable path to:

/usr/local/lib/prince/bin/princedebug

This should generate two temporary files containing debug information, /tmp/prince.debug and /tmp/prince.strace, which you can email to me (mikeday@yeslogic.com) to investigate the problem.
zephyr103
Hi it created /tmp/prince.debug but not /tmp/prince.strace. I don't think I will continue using Prince at this point in time but thanks for your quick reply.
mikeday
Okay no problem. Let us know if you would like us to take a look, as we are always eager to make Prince easier to use if we can. :)