So, to access Crystal Reports from PHP, the following code is used:
$crapp = new COM("CrystalDesignRunTime.Application");
$creport = $crapp->OpenReport("d:\\athermal\\reports\\backlog.rpt", 1);
$creport->SelectPrinter("winspool", "HP LaserJet 1200 Series PCL", "Ne01:");
$creport->PaperOrientation = 0;
$creport->PrintOut(False);
aap
Andrew Powell wrote:
I am receiving an error when attempting to use the SelectPrinter method in the CrystalDesignRunTime.Application COM object. The following code:
-----
$crapp = new COM("CrystalDesignRunTime.Application");
$creport = $crapp->OpenReport("d:\\athermal\\reports\\backlog.rpt", 1);
$creport->SelectPrinter("winspool", "HP LaserJet 1200 Series PCL", "Ne01:");
print "DEBUG|".$creport->DriverName."|".$creport->PrinterName."|".$creport->PortName."|";
$creport->PrintOut(False); ----- Produces the following output: ----- Content-type: text/html X-Powered-By: PHP/4.3.1
winspool|HP LaserJet 1200 Series PCL|Ne01:|<br />
<b>Warning</b>: (null)(): Invoke() failed: Exception occurred.
<b>Source</b>: Crystal Reports ActiveX Designer <b>Description</b>:
Error starting print job. Please check your printer or network connection. in
<b>d:\athermal\temp\test.php</b> on line <b>7</b><br />
-----
Other items to note:
- When the SelectPrinter line is commented out, the report prints fine to the default printer and the DEBUG line prints "DEBUG|||".
- If the PrintOut line is commented out, the DEBUG line prints "DEBUG|winspool|HP LaserJet 1200 Series PCL|Ne01:|" without any error.
- If the PortName is not specified, or specified incorrectly on the SelectPrinter line, it is printed correctly on the DEBUG line. (i.e. if "Ne00:" is specified on the SelectPrinter line, "Ne01:" is reported on the DEBUG line.)
I am in the process of converting an Intranet application from CGI4VB to PHP. Some of the scripts call Crystal Reports RDC to print to either PDF or their printer, which is mapped through the network on the server. I therefore need to call the SelectPrinter method. Any workarounds or patches for this would be very helpful.
aap
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php