Page 1 of 1

PHP Printing Help

Posted: Fri Nov 02, 2007 4:35 pm
by ladiesduck
I am working to port over a set of Inkjet print request pages from an OS X based server to a Windows 2003 one. While I have worked out most of the bugs there are a couple that elude me. The main one that I would like help on is to fix the mechanism that automatically prints a sheet of paper with the request when it is submitted online.

The code below is what works on the OS X server:

Code: Select all

//create new file
	$ourFileName = "./uploads/order3800.txt";
	$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
 	fwrite($ourFileHandle, $print_message); 
				
	//close file
 	fclose($ourFileHandle); 				
 	//systems calls to print and delete the file called "order"
 	system("lpr ./uploads/order3800.txt");
 	system("rm ./uploads/order3800.txt");
All the code seems to work fine on the Windows server except for the line that actually prints the file. I tried replacing "lpr" with "print" but I got the error "Unable to initialize device PRN". I googled this error and followed the instructions to map the networked printer to the DOS LP1 port but it did not work. Is there either a way to fix this or a better way to print using PHP?

Thanks a ton.

Jake

Posted: Fri Nov 02, 2007 5:24 pm
by Christopher
Probably because the printer is not on PRN:. Look into the parameters for lpr, but I think is would be something like:

Code: Select all

system('lpr -P HPLaserjet  ./uploads/order3800.txt');
If you can configure your installation you might be interested in installing this:

http://www.php.net/manual/en/ref.printer.php

Posted: Sat Nov 03, 2007 11:44 pm
by ladiesduck
I looked up the syntax for lpr and came up with this page.

http://www.microsoft.com/resources/docu ... x?mfr=true

When I try to use just

Code: Select all

system(lpr -P <printername> filename)
it gives me the below error message.

Sends a print job to a network printer Usage: lpr -S server -P printer [-C class] [-J job] [-o option] [-x] [-d] filename Options: -S server Name or ipaddress of the host providing lpd service -P printer Name of the print queue -C class Job classification for use on the burst page -J job Job name to print on the burst page -o option Indicates type of the file (by default assumes a text file) Use "-o l" for binary (e.g. postscript) files -x Compatibility with SunOS 4.1.x and prior -d Send data file first

When I try to include a server the printer is hosted on like so

Code: Select all

system(lpr -S <server IP> -P <printername> filename)
I get no error message but it does not print.

What am I doing wrong?

Posted: Thu Nov 08, 2007 8:24 am
by ladiesduck
Does anyone think they could help me on the syntax for this?

Posted: Thu Nov 08, 2007 9:05 am
by John Cartwright
Did you replace "server ip", "printername" and "filename" with the appropriate values?

(I had to ask)

Posted: Thu Nov 08, 2007 9:13 am
by ladiesduck
Hahah I understand.

I replaced the IP with our Papercut server that the printer is hosted on, the printer with the queue name on that server, and the filename with the filename.

Posted: Wed Nov 14, 2007 7:54 pm
by ladiesduck
Sorry to keep harping on this but I still don't have an answer to my printing question.

Anyone?