Re: Client/Server Printing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 20, 2009, at 9:16 AM, Paul M Foster wrote:

I'd like a side check on what I'm doing to print on our internal
network.

We have an internal server/site which uses PHP code I've written to
"run" the business-- invoicing, A/P, inventory, etc. Some things, like
invoices and reports, need to be printed. Now remember, the code is on
the server, and we access it from our client machines on our desks. When
we print, we do so to our local printers, attached to the client
machines.

So the best way I could think of to making printing work was to generate
PDFs of whatever needs to be printed, dump the PDF on the server, and
provide a link to the PDF on the web page. The user clicks on the
generated PDF, and his/her browser opens up Acrobat or xpdf, and prints
from that application to their local machine.

Is that a reasonable way to implement this? Any better ideas?

Paul

We've addressed this issue in two ways. Originally our application was locally hosted. The solution for us was:

<?php
if ($windows) {
exec ("psexec.exe -d -i -w ". escapeshellarg($filepath) ." -u $user -p ". escapeshellcmd ($pass) . " -e gswin32c.exe -q -dNOPAUSE - dNOPROMPT -dQUIET -dBATCH -dNumCopies=$copies -sDEVICE=msinwpr2 - sOutputFile=\"\\\\spool\\$printerShare\" \"$pdfFilepath\" 2>&1");
}
else {
exec ("/usr/bin/lpr -# $copies -P ". escapeshellarg($printerShare) ." \"$pdfFilepath\" 2>&1");
}
?>

The Windows version uses psexec to call ghostscript. So you do have to use third-party utilities for Windows (but they are small). However, if on *nix, then you can use the built in lpr. Of course, just put that code in a function that is called when clicked on a link to print.

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
http://www.ghostscript.com/

Our online solution uses a third-party utility for printing (Cloverleaf/Secure Courier). Essentially we have a (print) server and each of our clients have a client-version that connects to the print server. In our application, we use sockets to send print jobs to the server. The server then divvies out the print jobs to the specific client id specified in the data sent through the socket. However, since all your servers/clients are local, the first option may be more realistic.

Hope that helps,

~Philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux