LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Printing to a Zebra printer using a php aplication web (https://www.linuxquestions.org/questions/programming-9/printing-to-a-zebra-printer-using-a-php-aplication-web-786481/)

khriz 02-02-2010 12:17 PM

Printing to a Zebra printer using a php aplication web
 
Hi Everyone!! :)

I have a web page with php and xajax, and I'm trying to generate a barcode, and send it to a Zebra printer. I have no problems with the barcode, the issue here is, how can I send this barcode to the Zebra printer.

In the client side, if I type lpr -Praw file.txt, it works. But how can I do the same in my php web page?

I hope you guys can help me!!

Thanks in advance!

Guttorm 02-03-2010 12:50 PM

Hi

Is the printer connected to the server or the to clients? If it's the server you can just use shell_exec or similar. But if it's the client it's a little more tricky. You can Javascript's window.print() but if it's text you can't use Javascript, so I think you will need to put the text in a (i)frame and then do something like "top.frames.frameName.print()". The frame can be hidden on the page. Also, it will not actually print, but bring up a box where people will have to click Ok. If webpages could print themselves, it would be too annoying.

khriz 02-03-2010 01:05 PM

Thanks for answer.

The printer is connected to the clients. In deed, I'm trying to do it like this:
"lpr -P printer user@hostname < file_to_print"

where the "file_to_print" is the file created in the server.

Do you have any other better idea?

Thanks!!

Guttorm 02-03-2010 01:33 PM

Hmm

So all the clients are printer servers? Then it has nothing to do with php or web pages. You can send the job to their server, but I think you need something like - H $_SERVER['REMOTE_ADDR'] and -U $username and so on. I'd play with the command line and read man lpr and so on. If you can "mess" with the clients, it could be easier to just set up ssh keys to all of them so you can execute commands from the server. Then you could just shell_exec("ssh $hostname lpr -Praw <file_to_print").

khriz 02-04-2010 07:58 AM

Thanks Guttorm

I think I'll do it, this way. There's no problem for me to set up ssh keys on clients.

Thanks again.

khriz 02-04-2010 12:28 PM

How can I put "SOLVED" this thread?

FatButtLarry 02-22-2012 11:36 PM

I still feel this is relevant to the OPs question, but this is a browser applet that seems to do as described. Hope it will help some future Google searches:

http://code.google.com/p/jzebra/


All times are GMT -5. The time now is 05:36 AM.