王子xml似乎不起作用

Ive created a test page to test using Prince xml but this code doesn't seem to work.

index.php

require_once("prince.php");

$prince = new Prince('www1.must.edu.ph/tts/prince/Engine/bin/prince.exe');
$prince->setHTML(true);

$html = file_get_contents("reportHeader.html");

$ret = $prince->convert_string_to_file($html,'www1.must.edu.ph/tts/prince/Engine/bin/pink.pdf');

echo $html;

if($ret)
echo "converted";
else
echo "not";

whenever I access the page, there is no error.. it just displays the echoed $html and 'not'..

Problem 1:

I spotted the problem. You run PHP code in an .html ? Change the file extension to .php and re-upload to PHP-enabled hosting server & retry.

Problem 2:

The constructor does not set correctly. The constructor requires an absolute path on server, instead of an URL. The readme.html already mentioned this. It should look like:

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

In read me, it said:

On Windows, be sure to specify the path to the prince.exe file located within the Engine\bin subfolder of the Prince installation.

Note: Most of the PHP-enabled hosting server are NOT Windows-based; even it's Windows-based, it won't allow you to execute .exe .

This happened to me, so I used SSH to access my server and realized that I did not have a font library installed. If you are using something like CentOS, then you will need to install a font library first. I found this helpful http://blog.whatgeek.com.pt/2011/11/10/install-core-fonts-centos-6/

Running Prince on a virtual box on my Mac using the YesLogic PHP wrapper and parsing the PHP files with a web browser. No PDF output, no errors reported by the wrapper.

The answers above didn't resolve the issue for me.

So I parsed the PHP files from the command line using 'php -f index.php' and it worked. Stupid mistake on my part - my PHP files simply didn't have the correct permissions.