|
|
Printing a form directly to a PCL printer (Linux)
Posted by: david on Jan 05, 2006 - 06:17 PM
php-printing
|
|
Let's say that you've built a web application with neat html tables & forms, and you want your users to be able to click on a button and send the page directly to a PCL printer from your app. Or you want the web application to automatically print the html form to a PCL printer. Here's how to do it with PHP:
Output the html to a temporary file, e.g. fopen($tmp_file, "w+") or die ("Print error: Can't write file $tmp_file.");
convert the html file into a postscript file using the perl command line utility "html2ps" (download html2ps) - e.g. exec("html2ps /tmp/form.html > /tmp/form.ps");
convert the postscript file to PC using ghostscript, e.g. exec("gs -sDEVICE=laserjet -sPAPERSIZE=letter -sOutputFile=/tmp/form.pcl -dNOPAUSE -q /tmp/form.ps -c quit"); In this case you are converting the file form.ps into form.pcl
simply use lpr -P$name_of_your_print_queue to print the file - e.g. exec("lpr -Pmy_laserjet /tmp/form.pcl"); Now this is assuming that you've already have the print queue setup - voila!
|
|
| Printing a form directly to a PCL printer (Linux) | Log-in or register a new user account | 2 Reviews/Comments |
|
| Reviews and Comments are opinion statements made by the author. They do not necessarily represent the opinions of the site editor. |
Re: Printing a form directly to a PCL printer (Linux)
by zander on Dec 25, 2006 - 01:12 AM
(User information | Send a message)
|
This gives me a great start however do you have any suggestions regarding the use of PCL commands to specify how the print job should be handled?
Two examples I have are:
Specifying that a job should be printed in duplex.
Specifying that particular pages should use paper from particular trays.
I just can't find ANY examples of how to do this - maybe because its printer specific?
|
Re: Printing a form directly to a PCL printer (Linux)
by David on Dec 25, 2006 - 02:45 AM
(User information | Send a message)
|
I think you have to find the specific PCL command codes to do the duplex/specific tray functions. I am not versed in PCL so I can't help you further, but maybe there's some reference out there, e.g.:
http://support.microsoft.com/kb/194306
The PCL command for duplex appears to be "an ampersand, lower-case L, numeric 1, and upper-case S", like: &l1S
Good luck!
|
|