Forum How do I...?

Get Prince running on windows PHP

slb813
I have installed Prince to folder: D:\Prince, and load with the code:

$prince = new Prince('D:\\Prince\\Engine\\bin');
if(!$prince)
{ die("<p>Prince instantiation failed</p>"); }
else
{ echo "Prince instantiation OK<br />"; }

I get the OK message. My login user has the authority to read and write to the folders I want to save the PDF in. When I run Prince manually aginst the same file that I am attempting to convert via my PHP script, it works with no errors. However when I attempt to run through my PHP script that attempts to setlog, then sethtml, then convert_string_to_file I get no results of any kind logfile or PDF.

$Messages = array();

$ConversionInformation = $prince->setlog('d:\\itservices\\xampp\\htdocs\\warranty\\email\\LOG'.$WRRow["WarrantyID"].'.log');
$ConversionInformation = $prince->setHTML(1);
$ConversionInformation = $prince->convert_string_to_file($HTMLPage, 'd:\\itservices\\xampp\\htdocs\\warranty\\email\\WR'.$WRRow["WarrantyID"].'.pdf', $Messages);
//$ConversionInformation = $prince->convert_string_to_passthru($HTMLPage);
if(!$ConversionInformation)
{
echo "<br> Conversion Failure(string to passthrough) !!!";
echo '<br>Converted Variable: '.$ConversionInformation;
echo '<br>msgs array: '.$Messages[0];
echo "<br>";
}
else
{
echo "<br>Conversion Sucess ......";
echo '<br>Converted Variable: '.$ConversionInformation;
echo '<br>msgs array: '.print_r($Messages);
echo "<br>";
}

My HTML PAGE looks like this.

<html>
<head>
<title>Check Request</title>

<style type="text/css">

table { text-align: left;
font-family: Calibri;
font-weight: normal;
font-size: 10pt;
color: white;
background-color: none;
width: 850px;
border-bottom: 3px solid darkblue;
border-top: none;
border-left: none;
border-right: none;
border-collapse: collapse;
border-spacing: 0px; }

table.Delv { text-align: left;
font-family: Calibri;
font-weight: normal;
font-size: 10pt;
color: white;
background-color: none;
width: 500px;
border-bottom: none;
border-top: none;
border-left: none;
border-right: none;
border-collapse: collapse;
border-spacing: 0px; }

table.Sig { text-align: Center;
font-family: Calibri;
font-weight: normal;
font-size: 10pt;
color: white;
background-color: none;
width: 850px;
border: none;
border-collapse: collapse;
border-spacing: 0px; }

table.Invoice { text-align: left;
font-family: Calibri;
font-weight: normal;
font-size: 10pt;
color: white;
background-color: none;
width: 600px;
border: 1px solid Black;
border-collapse: collapse;
border-spacing: 0px; }

tr { border-bottom: none;
border-top: none;
border-left: none;
border-right: none;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
background-color: purple;
text-align: right;
text-indent: 0px;
font-family: Calibri;
font-weight: normal;
font-size: 10pt;
color: black; }

th { border-top: none;
border-bottom: 2px Solid Black;
border-left: 1px Solid Black;
border-right: 1px Solid Black;
background-color: CornSilk;
text-align: Center;
text-indent: 0px;
font-family: Calibri;
font-weight: normal;
font-size: 11pt;
color: Black; }

td { border: none;
padding: 0px;
background-color: Ivory;
text-align: left;
text-indent: 0px;
font-family: Calibri;
font-weight: normal;
font-size: 10pt;
color: Black; }


td.DelvT { text-align: Right; }

td.Invoice { border: 1px Solid Black;
text-align: Center; }

td.tital { padding-left: 10px;
text-align: right;
font-weight: bold; }

td.Addr { padding-left: 10px;
vertical-align:text-top;
font-weight: bold; }

td.Heading { text-align: Center;
font-weight: Bold;
font-size: 16pt; }

td.Sig { background-color: White;
text-align: Center;
font-size: 12pt; }

td.UnderSig { background-color: White;
text-align: Center;
font-size: 8pt; }

form { margin_top: 0px;
margin_bottom: 0px;
margin_left: 0px;
margin_right: 0px;
padding: 0px; }

input.text { background-color: lightblue;
color: black;
font-family: Calibri;
font-size: 10pt;
font-weight:normal;
text-align: left;
text-indent: 2px;
border-style: none;
border-width: 1px;
overflow:hidden;}

input.Invoice { background-color: Beige;
color: black;
font-family: Calibri;
font-size: 10pt;
font-weight:normal;
text-align: Right;
text-indent: 2px;
border-bottom: 1px Solid Black;
border-top: none;
border-left: none;
border-right: none;
overflow:hidden;}

input.Amount { background-color: BlanchedAlmond ;
color: black;
font-family: Calibri;
font-size: 10pt;
font-weight:normal;
text-align: Right;
text-indent: 2px;
border-bottom: 1px Solid Black;
border-top: none;
border-left: none;
border-right: none;
overflow:hidden;}

body { padding: 0px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
font-family: Calibri;
font-weight: normal;
font-size: 10pt;
color: Black;
background-image: none;
background-repeat:repeat-y; }

</style>

</head>
<body>

<form name='CheckRequest'
method='post'>

<table>
<tr>
<td class='Heading' colspan='8'>Check Request</td>
</tr>
<tr>
<td colspan='8'> </td>
</tr>

<tr>
<td class='tital'>Warranty Record: </td>
<td><input type='text'
name='WarrantyRecord'
id='WarrantyRecord'
class='text'
value='5478'
readonly='readonly'
size='8'
maxlength='8'> </td>
<td class='tital'colspan='6'> </td>
</tr>

<tr>
<td class='tital'>Date of request:</td>
<td><input type='text'
name='CurrentDate'
id='CurrentDate'
class='text'
value='01/10/2012'
readonly='readonly'
size='8'
maxlength='8'> </td>
<td class='tital'colspan='3'> </td>
<td class='tital' colspan='2'>Amount Requested:</td>
<td><input type='text'
name='CheckValue'
id='CheckValue'
class='text'
value=''
tabindex='500'
size='15'
maxlength='8'> </td>
</tr>
<tr>
<td class='tital'colspan='8'> </td>
</tr>
<tr>
<td class='tital'>Payably To: </td>
<td colspan='5'> <input type='text'
name='PayableTo'
id='PayableTo'
class='text'
value='Spartan'
tabindex='100'
size='55'
maxlength='55'> </td>
<td class='tital' colspan='2'> </td>
</tr>
<tr>
<td class='tital'>Address: </td>
<td colspan='5'> <input type='text'
name='Address1'
id='Address1'
class='text'
tabindex='101'
size='55'
maxlength='55'> </td>
<td class='tital' colspan='2'> </td>
</tr>
<tr>
<td class='tital'> </td>
<td colspan='7'> <input type='text'
name='Address2'
id='Address2'
class='text'
tabindex='102'
size='55'
maxlength='55'> </td>
</tr>
<tr>
<td class='tital'>City: </td>
<td colspan='3'> <input type='text'
name='City'
id='City'
class='text'
tabindex='103'
size='35'
maxlength='35'> </td>
<td class='tital'>State: </td>
<td> <input type='text'
name='State'
id='State'
class='text'
tabindex='104'
size='12'
maxlength='25'> </td>
<td class='tital'>Zip: </td>
<td> <input type='text'
name='Zip'
id='Zip'
class='text'
tabindex='105'
size='10'
maxlength='25'> </td>
</tr>
<tr>
<td class='tital'colspan='8'> </td>
</tr>
<tr>
<td class='tital'>Purpose: </td>
<td colspan='7'> <input type='text'
name='Purpose'
id='Purpose'
class='text'
value=''
tabindex='106'
size='85'
maxlength='85'> </td>
</tr>
<tr>
<td class='Heading'colspan='8'>
<table class='Invoice'>
<thead>
<tr>
<th>Invoice</th>
<th>Amount</th>
<th>Invoice</th>
<th>Amount</th>
<th>Invoice</th>
<th>Amount</th>
<th>Invoice</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td class='Invoice'><input type='text' name='Invoice1' id='Invoice1' class='Invoice' tabindex='107' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount1' id='Amount1' class='Amount' tabindex='108' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice2' id='Invoice2' class='Invoice' tabindex='109' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount2' id='Amount2' class='Amount' tabindex='110' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice3' id='Invoice3' class='Invoice' tabindex='111' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount3' id='Amount3' class='Amount' tabindex='112' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice4' id='Invoice4' class='Invoice' tabindex='113' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount4' id='Amount4' class='Amount' tabindex='114' value='' size='6' maxlength='6'></td>
</tr>
<tr>
<td class='Invoice'><input type='text' name='Invoice5' id='Invoice5' class='Invoice' tabindex='115' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount5' id='Amount5' class='Amount' tabindex='116' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice6' id='Invoice6' class='Invoice' tabindex='117' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount6' id='Amount6' class='Amount' tabindex='118' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice7' id='Invoice7' class='Invoice' tabindex='119' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount7' id='Amount7' class='Amount' tabindex='120' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice8' id='Invoice8' class='Invoice' tabindex='121' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount8' id='Amount8' class='Amount' tabindex='122' value='' size='6' maxlength='6'></td>
</tr>
<tr>
<td class='Invoice'><input type='text' name='Invoice9' id='Invoice9' class='Invoice' tabindex='123' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount9' id='Amount9' class='Amount' tabindex='124' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice10' id='Invoice10' class='Invoice' tabindex='125' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount10' id='Amount10' class='Amount' tabindex='126' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice11' id='Invoice11' class='Invoice' tabindex='127' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount11' id='Amount11' class='Amount' tabindex='128' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice12' id='Invoice12' class='Invoice' tabindex='129' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount12' id='Amount12' class='Amount' tabindex='130' value='' size='6' maxlength='6'></td>
</tr>
<tr>
<td class='Invoice'><input type='text' name='Invoice13' id='Invoice13' class='Invoice' tabindex='131' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount13' id='Amount13' class='Amount' tabindex='132' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice14' id='Invoice14' class='Invoice' tabindex='133' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount14' id='Amount14' class='Amount' tabindex='134' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice15' id='Invoice15' class='Invoice' tabindex='135' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount15' id='Amount15' class='Amount' tabindex='136' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Invoice16' id='Invoice16' class='Invoice' tabindex='137' value='' size='6' maxlength='6'></td>
<td class='Invoice'><input type='text' name='Amount16' id='Amount16' class='Amount' tabindex='138' value='' size='6' maxlength='6'></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class='tital'colspan='8'> </td>
</tr>
<tr>
<td class='tital'colspan='8'> </td>
</tr>
<tr>
<td class='tital'>Date Wanted: </td>
<td colspan='3'> <input type='text'
name='DateWanted'
id='DateWanted'
class='text'
tabindex='139'
size='10'
maxlength='10'> </td>
<td class='tital'colspan='4'></td>
</tr>
<tr>
<td class='tital'colspan='8'> </td>
</tr>

<tr>
<td class='tital'> </td>
<td> <input type='radio'
name='Delivery'
id='Delivery'
value='DeliverTo'
tabindex='140'
onClick='addDelivery()'> Deliver To</td>

<td class='Addr'colspan='8'><div id='DeliveryAddress'></div></td>

</tr>

<tr>
<td class='tital'> </td>
<td> <input type='radio'
name='Delivery'
id='Delivery'
value='MailIt'
tabindex='147'
onClick='removeDelivery()'
checked='checked'> Mail To Payee</td>
<td class='tital'colspan='7'></td>
</tr>

<tr>
<td class='tital'colspan='8'> </td>
</tr>
<tr>
<td class='tital'>Charge to Acct: </td>
<td colspan='3'> <input type='text'
name='ChargeAccount'
id='ChargeAccount'
class='text'
tabindex='148'
size='35'
maxlength='35'> </td>
<td class='tital'colspan='4'></td>
</tr>
</table>

<table class='Sig'>
<tr><td class='Sig'> </td></tr>
<tr><td class='Sig'>______________________________________________________</td></tr>
<tr><td class='UnderSig'><i>Originator Signature</i></td></tr>
<tr><td class='Sig'> </td></tr>
<tr><td class='Sig'>______________________________________________________</td></tr>
<tr><td class='UnderSig'><i>Department Executive Signature</i></td></tr>
<tr><td class='Sig'> </td></tr>
<tr><td class='Sig'>______________________________________________________</td></tr>
<tr><td class='UnderSig'><i>Accounting Executive Signature</i></td></tr>
<tr><td class='Sig'> </td></tr>
</table>

</form>
</body>
</html>


Has anyone, got a suggestion as to what I may be doing wrong?
mikeday
You need to specify the full path to the executable, eg. "D:\\Prince\\Engine\\bin\\prince.exe".
slb813
I made the changes , but still no PDF or Log for either string to file or string to passthru. I have verified that I have capability to write from both the client page and the server. When I run the user interface for Prince and convert the file, there is no prooblems in the log and it creates a pdf file.
mikeday
Can you try running this:
$output = system("D:\\Prince\\Engine\\bin\\prince.exe --version");

This will confirm that the Prince executable is being run, it should show something like this:
Prince 8.0
Copyright 2002-2011 YesLogic Pty. Ltd.
Non-commercial License
slb813
THis is what I am getting:
Prince instantiation OK
Prince 8.0 Copyright 2002-2011 YesLogic Pty. Ltd. Non-commercial License
Non-commercial License
Conversion Failure(string to File) !!!
Converted Variable:
msgs array:
mikeday
So PHP is clearly capable of running the Prince executable. Perhaps try calling setLog() with a file in a temporary directory, like C:\Windows\Temp\Prince.log, in case there is trouble writing to the log file?