Im working on a project where i need to use POS printer to generate the reciept. The client asked for a new request where the paper need to be cut automatically when the print has been done.. so that if he needs to print 10 recipts at a time it cuts 10 times and makes some difference.
I am having to make a few assumptions here.
The POS printer is connected to the client computer, not the PHP
server.
This is an internal application supporting Windows based POS terminals.
With this said, there are several Serial/COM port plugins available. We currently use an ActiveX plugin at work, though I wont make any recommendations -- I don't know enough about the alternatives. This will need to be installed/approved by the client computer.
Find the Make/Model of your printer and find the control codes for cutting the paper. They should be listed in the back of the manual. You will need to program your PHP script to output the correct data/control codes to the plugin to send to the printer.
Just for the record, I am not a fan of this solution.
Related
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.
I'm trying to develop a way to pull a list of printers (names and IPs at least), from a Windows print server. I plan to use this info in an external PHP-driven status website, running on a Linux webserver, which talks to the printers individually via SNMP. The SNMP communication is already functional. I just need a way of dynamically generating the list of printers it talks to, instead of hard coding all of the IPs/DNS Hostnames.
The idea here is that I do this entirely without touching or changing the print server(s), printers, or the underlying webserver. The only thing under my control is a shared, non-administrative CPanel account.
My research so far has led me to three potential leads. I have next to no experience with any of them.
1) The PHP printer_list command, which is part of the PECL extension. At the moment our webserver does not have this extension installed, and I'd prefer not to make that request unless I know it will work for my purposes.
2) The lpstat Linux command, part of CUPS. I've tried using it per the man page and it seems to just sit there doing nothing. I don't know if this is because it's expecting a CUPS response which I figure it will not be getting from a Windows server, or if this might be a firewall issue.
3) SMB or WMI queries of some sort. I have no idea how to even begin with these.
I'd like to ask for a recommendation on where to start. This has been a very troubling project to research because 90% of search results are about people wanting to print. Another 8% are about people polling a local system for printer info. The rest are black magic and proprietary enterprise solutions.
Any insights are very much appreciated.
== Matt
I am using WMI effectively to fetch printer information over network using :
Select * FROM Win32_Printer
To begin:
1 - Run wbemtest from run window.
2 - Connect to any machine where you know printers are configured.
3 - There is query option, copy Select * FROM Win32_Printer
4 - Step 4 will return you table, click on Show MOF, it will provide you printer information. Viola, you are done.
5 - I have used C# ManagementObjectSearcher & ManagementObjectCollection and it is pretty straightforward and easy to use.
There are some pros and cons of using WMI. Read it online.
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.
I am currently adding features to a PHP web application for a client. They require to be able to print some raw data to a ticket / thermal printer direct from the php which will be run on an internet browser from a self service kiosk.
The data needs to printed on the local kiosk's in built ticket printer.
From my preliminary research I understand that I must perform this task using javascript for any client side actions and wondered if anybody knew of any method or example function that will allow the printing of a string to a designated printer / com port which would bypass the printer dialog box?
Thanks in advance for any help
Alex
This plugin requires Java installed client-side, but after the first security prompt, this will do what you need (works with Linux, Mac, Windows, Solaris -- anything that can run Java desktop application)
https://github.com/qzind/tray
If it has to be cross browser and platform independent, stop right now and run. There is NOT way, and I mean NO way for Javascript to access information about printers, margins, paper size, and all the variables in printers. Even if your browser has some sort of fast print button, print using default settings and default printers, you have no idea the type of paper, the ink, the margins, etc, and you could be printing on A4 paper, or in the US, our legal size, 8.5" X 11.5".
Browsers, for security, do NOT give javascript any access to this information that is supplied to them by the Windows API and the printer drivers. The closest possible that I know of, is in small networks, where the variables are known, and configured using Internet Explorer's JScript or ActiveX. Short of this, your only other easy option is to write your own web browser/addon/plugin, or to modify one that will run on these platforms, that has this built in capability.
More info available here.
EDIT: Though if you really want to make your life simple, tell them to install Firefox, and check out this article for the simplest solution possible. Also, have you considered VBScript? It has this capability, I've seen it done before.
Not possible, at least not without some extra steps.
Without knowing more about the kiosk environment, you have three main options:
1). Install a Web service on the local kiosk. This Web service would manage printing and ultimately be the most extensible solution.
2). Create a plug-in for the print service. This would be uglier, and really tie you to a single browser solution forever.
3). Wrap the browser in custom code to allow external calls. Again, somewhat ugly, but since you're running a kiosk, you're likely to have some sort of custom/extensible wrapper anyway.
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.