0

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'..

jim
  • 1
  • 1
  • 3
  • @ShivanRaptor thats the problem..It doesn't displays any error..It will just echo not.. – jim Oct 21 '13 at 07:57
  • The syntax is not readily available online, but I think `convert_string_to_file` is the problem - it can only write to a local PDF, and you're trying to write to a URL. – halfer Oct 21 '13 at 08:30
  • @halfer i have the access to its server and even if I write the whole path it still doesn't work.. – jim Oct 21 '13 at 10:13
  • OK, please update your code with the changes you've recently made - I take it you've fixed "problem 2" as pointed out by Shivan below? – halfer Oct 21 '13 at 13:03

3 Answers3

1

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 .

Raptor
  • 53,206
  • 45
  • 230
  • 366
0

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/

scott
  • 583
  • 6
  • 11
0

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.

supernifty
  • 4,171
  • 2
  • 32
  • 24