Forum How do I...?

Prince PHP interface never returns true on success in Linux

lncdk
I had been beating my head against this for days, and finally figured out the problem and the solution.

There is a bug in the supplied prince.php class that will cause it always return false, even upon success.

The private function readMessages contains the following line:

if (substr($line, (strlen($line) - 2), 2) == chr(13) . chr(10))

It is looking to see if the process returns a carriage return and a line feed at the end of $line. My guess is that this was written on a windows box, as in Linux the two characters that are actually returned are a lower case "s" and a carriage return, thus the function will never return true, even when it has successfully rendered a PDF. I modified the check to move back one character and check for a pair of "ss" characters, and it works fine, though there are many other ways to do this. I hope this helps someone else who may have had a similar problem, and suggest that this is a bug that should be fixed.

Dan
mikeday
Ah, excellent work! It seems that we have been bitten by the infamous carriage return bug once again. Thank you very much for bringing it to our attention.