how to give command to printer without user interaction (without print dialog) - php

I am creating an application in PHP and want to give a command to a printer but problem is that there are more than two printers and I want to give the command to a different printer by clicking on different button without the print dialog.

you can use:
printer_list()
function to get list of printers attached to server, and then use:
printer_open
to open connection to printer providing printer name as parameter to the function.
I hope that helps you to some extent

In online web applications you can't.
A workaround could be to write Java Applet or in IE you can do this via ActiveX controls.

Related

How to print from the web to a local thermal printer connected by usb?

First of all, sorry for my English, I have been with this problem for quite a few days. I will comment on my situation: I am doing an online ordering system, where once an order is created the ticket printing is triggered. I have tried using Google Cloud Print, it prints but it takes a long time and it does not work as it should, I tried a library called mike42, it prints perfect but not from a website.
The system is in a hosting and I am using PHP together with slim 3, if any of you know how to solve this I would really appreciate it.
The result I want (to be more specific) is the following: The employed user logs on the web (system hosted in the hosting), goes to the orders menu, when he clicks on create the order, this function is executed and prints the ticket directly on the thermal printer connected to the local machine. The same works only if the web is on the local server, which is not what I want.
The title is clear and complete. Printing must take place in client side browser. Client may be connected to a cloud based accounting or purchase system and POS termal printer is connected through a USB port. Computer mat be a zero client with just a browser.
Well, PHP is a server side language, that means it has no communication with the hardware of the local machine.
I've already had to do similar work, and there are two possible solutions:
1- Install PHP on a machine connected to the printer directly, and then print, which is a little impracticable since the server would have to be physically on site.
2 - Generate an output in text formatted for the width of the print and use the window.print () javascript function to call up the print screen, and the user would just click on print.
When I needed it I ended up opting for the second alternative, and it worked well, it is a bit boring to get the print size right, but it worked well.

Networked Zebra Label Printer using PHP/AJAX

I have been tasked with figuring out how to get our zebra label printers(mostly the 420t models) to print over the network from calls in one of our PHP applications. I've come up with a couple of ideas but wanted to run it past people more knowledgeable than I am before I start down one path or the other.
Setup a machine to be a print server which has the zebra on USB as the default printer. I'd have to write some sort of print queue script or something to run on this machine.
Get a zebra printer with a network port and directly send print requests to it. I have seen a couple of other SO questions about it and it seems to require sending in the RAW over sockets. From the answers on these questions it seemed like there were some issues with doing this.
Send the print request via FTP somehow as mentioned in a few places.
Use either 1 or 2 with the LPR library.
What do you guys suggest?
I use intersively the second solution at work, ie using network enabled printers, and sending them (via cURL to the printers IP) data from a .prn file with my replacements.
The models we use are G4K20d.

Printing To a Receipt Printer (pdf)

I would like to use a receipt printer with my web based POS.. Before i go any further i know you can not force print a receipt from the browser and the only options are to do it via PHP, and cups, which is not an option or a Java Applet, Prefer no to..
My question is im looking at the Star Micronics TSP-100 and would like to send a PDF to it. I have looked all over and can not find if receipt printers will print standard PDF's..
Also if anyone has any experience with this any tips would be helpful.. Ie what page size do you set?
EDIT: The server platform is Linux, PHP / MYSQL and im using Yii with the epdf plugin. PDF generation is not the issue. It unclear if a receipt printer can print a pdf. Also what page properties should i use when setting up the document. Ie width / height.. Width i know is determined by the printer, but im curious to height.
You cannot force a receipt print from the browser but you can use an Active X control (in IE) and print the receipt locally.
What I did was:
1. generate the pdf on the server
2. call an Active X command to download the PDF using wget (this puts the file on the local machine.
objShell.run('cmd /K wget -P /pos/invoices/ http://url.com/pos/<?php echo $filename;?>',0,false);
call an Active x command to print the local PDF using Adobe command line
objShell.run('"C:\\Program Files (x86)\\Adobe\\Reader 11.0\\Reader\\AcroRd32.exe" /h /s /o /t "C:\\pos\\<?php echo $filename;?>"');
In order to print to your receipt printer, you just need to set it as default printer or change the Active x commands to include the printer name. I am still working on the paper size issue.
I realize you are using Linux so the Windows commands will not work but the process is the same.
Your question is not too clear. You did not mention which operating system are you using.
I think, you have two problems
Printing a PDF from PHP. I found this Adobe Reader Command Line Reference
Generating a PDF from a template. I can recommend wkhtmltopdf, which is exists for MS-Windows and Linux platforms. It uses WebKit to render page, so the source is plain HTML+CSS.

printing from web(PHP) to local printer POS (point-of-sale) directly

Is it possible to print from a website directly to the printer ?
maybe if i first write the file than save it to a local folder, and after saving it would be run the printer? like printer spooling?
I printing now with web dialog ... ut would like to send it direct to the local printer.
As far as I understand you want a solution for server-side printing, right?
If it is a network-enabled printer that's connected to the server that serves the web page, you could use the lp Linux command. On Windows you can use the lpr command.
The file to print could be generated from the web page code with wkhtmltopdf or mpdf.
If it's not on the same network, you could set up a script on the printer network that checks an email address and sends the attachments from specific emails to the printer.
js print function should do, but you will get the dialogue to confirm printing, this is a security measure on the browser to prevent hackers from using your printer.
You can overcome this dialogue in the browser setting.

php handling POS printer and cashdrawer

i have been googling around wether PHP can handle to print a receipt and kick the cash drawer through a web server?
i read about PHP-GTK2, but it seems cant handle trhough a web server, only for desktop use or standalong apps. is there anyway or sample code or links would be appriciated, please!
You will have to have software running on the client machine the drawer is hooked up to if not running a cash drawer receipt printer. You are not able to directly access the client machine for security reasons. Most cashdrawers connect via a printer that also sends the signal to pop the drawer on receipt printing. You would be able to pop the drawer in this method because the browser can be set up to print to that receipt printer just like any other normal printer.
If you are not using a receipt printer you can look into a fairly new drawer made by APG that is networked but last I knew it was not available yet.
Ethernet cash drawer
You're talking about a browser-based POS? The question should be more along the lines of "can I control the drawer/printer from a browser". PHP's involvement with this process would be to generate the page attempting to control either device. PHP will never execute on the client-side, so can't do anything about the hardware. You'd need Javascript or some other API in the browser to talk to the hardware.
It's not beyond the realm of possibility to have a Java applet or Flash object kick the drawer open. A good number of them, as grantk noted, connect with a receipt printer and open on print -- or in some cases, when a certain character string is present. (I think.)
Now, since you can have JavaScript initiate a print, you could conceivably kick the drawer from any webpage. But, for the duration of the POS project I was working on, we never got the drawer auto-pop to work.) In the worst case, you can write a plugin to do the work. I'd try an applet first, of course.
However, if your PHP application runs on the same network as your POS stations, you can actually just add each printer to the server and print directly from the PHP app. And presumably, you can trigger the drawer similarly.
With WiFi enabled cash draws and printers I think you could be able to trigger a cash draw (located on a network) to open from anything that will kick off a web or socket request.
I have to build an EPOS system for work - as the old one is 20 years old and is crap! - plus building it yourself you have total control to design the stock and reporting exactly how you fancy.
Once I have played with the hardware I will report back :)
I know this is an old question, but the most simple solution is from within the printer/device configuration itself. Most POS printers have an option to trigger a drawer open, both on print or after printing. This goes for ALL Star, Citizen POS printers (or any POS printer for that matter). To access these settings, go into the device configuration options (in Windows based OS' - under Control Panel/Devices) and set it there.

Categories