Forum How do I...?

php missing arg

yusufdestina
Missing argument 2 for Prince::convert()

I can't get it working with PHP.
$pdf = new Prince('C:\Program Files\Prince\Engine\bin\prince.exe');
$pdf->convert2("xmlfile.xml", "out.pdf");


What am i doing wrong?
mikeday
This is caused by a limitation in the PHP wrapper that shows up when strict error checking is enabled.

We have fixed this issue and there is now an updated PHP interface that you can download from the accessories page.

Thank you for reporting the issue! :)
yusufdestina
$pdf = new Prince('C:\Program Files\Prince\Engine\bin\prince.exe');
$pdf->convert2($tmpfile, 'tmp/out.pdf');

The warnings are gone, but there is no pdf file generated.
The path to the exe is correct.
Is there a way I can check if there is communication between php and prince?

If I convert from the command line with my html file in the same dir as Engine/bin/prince.exe everything is ok, If i move the source file and enter ex:
$ prince C:\Dir01\Dir02\test.html C:\Dir01\Dir02\out.pdf
it fails with this error:
prince: warning: failed to load external entity "file:///C%3A/Program"
prince: C:\Program: error: could not load input file

In linux (Suse9.3) all works fine. I need it running on my win xp comp for local testing...
Tnx for your help!
mikeday
$pdf = new Prince('C:\Program Files\Prince\Engine\bin\prince.exe');
$pdf->convert2($tmpfile, 'tmp/out.pdf');

The 'tmp/out.pdf' path looks a bit suspicious; I think that it might be better to specify an absolute path for the PDF output to ensure that it is written to the correct directory.

$ prince C:\Dir01\Dir02\test.html C:\Dir01\Dir02\out.pdf
it fails with this error:
prince: warning: failed to load external entity "file:///C%3A/Program"
prince: C:\Program: error: could not load input file

Running Prince from the command-line with a path that contains spaces is a bit awkward, as "prince C:\Program Files\Blah" looks like two arguments not one: the first is "C:\Program" and the second is "Files\Blah"! Try wrapping the argument in quotes or using "Progra~1" instead of "Program Files".
lordlinton
I had this same error, so this solution might help someone:

$prince = new Prince("call \"C:\\Program Files\\Prince\\Engine\\bin\\prince.exe\"");


Steven.